Bundling¶
cosmofy bundle creates a Cosmopolitan Python bundle from your project.
How It Works¶
- Downloads Cosmopolitan Python - A universal Python binary from cosmo.zip
- Installs Dependencies - Uses
uvto collect your project's dependencies - Creates Bundle - Packages everything into a single executable
Entry Points¶
From pyproject.toml¶
By default, cosmofy bundle bundles all entry points defined in [project.scripts]:
Specific Entry Points¶
Bundle only specific entry points:
Standalone Scripts¶
Bundle a single Python script:
Note
Scripts must have inline dependencies defined using uv init --script or uv add --script.
Output¶
By default, bundles are placed in dist/:
Caching¶
Cosmopolitan Python is cached to avoid repeated downloads:
# Default cache location
~/.cache/cosmofy/
# Custom cache location
uvx cosmofy bundle --cache-dir /tmp/cosmofy-cache
# Disable cache
uvx cosmofy bundle --no-cache
Environment variables:
COSMOFY_CACHE_DIR- Custom cache directoryCOSMOFY_NO_CACHE- Disable caching
Custom Python URL¶
Override the Cosmopolitan Python download URL:
Or set COSMOFY_PYTHON_URL environment variable.
Bytecode Compilation¶
Compile Python files to bytecode (.pyc) for faster startup:
This uses the Cosmopolitan Python in the bundle to compile .py files. The trade-off is slightly larger bundle size for faster initial import times.
Output Format¶
Get structured JSON output instead of text:
The JSON output includes paths to all generated bundles:
This is useful for scripting and CI/CD pipelines.
Dry Run¶
See what would happen without making changes: