Skip to main content

A Python source minifier for scripts and small module graphs.

Project description

pymini

pymini minifies Python source code by simplifying syntax, shortening identifiers, and stripping unnecessary whitespace. Its primary multi-file workflow preserves package structure; one-file bundling is available as an explicit opt-in.

Status

This project is maintained as an AST-based minifier for Python 3.9+ code. It is best suited to scripts and small module graphs that use straightforward imports such as from module import name.

Installation

python3 -m pip install pymini

CLI

Package mode is the default and preserves the package tree:

pymini package src -o out

Legacy invocation without an explicit mode still defaults to package:

pymini src -o out

By default, pymini preserves module paths and public globals. When possible, it keeps the public surface stable by emitting aliases while still shortening internal names. To trade API stability for more aggressive compression:

pymini package src --rename-global-variables -o out

Bundle mode emits a single file and is better suited to app-style graphs than libraries:

pymini bundle src -o out/bundle.py

The legacy --single-file flag is still accepted as a compatibility alias for bundle mode.

Python API

from pymini import minify

sources, modules = minify(
    [
        "def square(x):\n    return x ** 2\n",
        "from main import square\nprint(square(3))\n",
    ],
    ["main", "side"],
)

Development

Install development dependencies and run the test suite:

python3 -m pip install -e ".[dev]"
python3 -m pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymini-0.1.2.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymini-0.1.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file pymini-0.1.2.tar.gz.

File metadata

  • Download URL: pymini-0.1.2.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pymini-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1e79f3a7ca563353151120b28e86cfa57e7ec2b9ab53b2e43564b86b681d1432
MD5 bda736382053fa1c00710af7b0cc2952
BLAKE2b-256 bcb73da87214a60ace803988876bf9c5205861912c3a89b6cc3977c4edd8efaf

See more details on using hashes here.

File details

Details for the file pymini-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pymini-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pymini-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f712cce605e0143dbf91895e95a7bd16eb55a7fda20121d7337819ab739ffb1
MD5 b08c17c2ad9bc9360e0bc464e3108632
BLAKE2b-256 2a2310bb8c0c2a7e26461558d095f442e507c6e0709b53151745385b67a21605

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page