Complete reference for all zipbundler command-line options.
Zipbundler supports a python -m zipapp compatible command-line interface that matches the standard library’s zipapp module exactly:
zipbundler SOURCE [OPTIONS]
Positional Arguments:
SOURCE: Source directory (or existing .pyz archive for --info)Options:
-o, --output OUTPUT: Output .pyz file path (required if SOURCE is an archive)-p, --python PYTHON: Python interpreter path for shebang line (default: no shebang)-m, --main MAIN: Main entry point as module:function or module (default: use existing __main__.py)-c, --compress: Compress files with deflate method (default: uncompressed)--info: Display the interpreter and metadata from an existing archive (see --info section below)--compat: Enable compatibility mode (reserved for future strict Python zipapp compatibility; currently no behavior changes)Examples:
# Basic usage (no shebang, uses __main__.py if present)
zipbundler src/myapp -o app.pyz
# With shebang and entry point
zipbundler src/myapp -o app.pyz -p "/usr/bin/env python3" -m "myapp:main"
# With compression (shorthand)
zipbundler src/myapp -o app.pyz -m "myapp:main" -c
# With compression (long form)
zipbundler src/myapp -o app.pyz -m "myapp:main" --compress
# Display info from existing archive
zipbundler app.pyz --info
# Display info from archive using directory auto-derivation
zipbundler myapp --info
# Modify existing archive (requires -o)
zipbundler app.pyz -o app_new.pyz -p "/usr/bin/env python3"
# Build with zipapp compatibility mode
zipbundler src/myapp -o app.pyz --compat
Compatibility Notes:
python -m zipapp interface exactlyzipapp.create_archive() and zipapp.get_interpreter()zipimport or importlib.pyz files--info CommandDisplay interpreter and metadata information from an existing archive.
zipbundler --info ARCHIVE
zipbundler --info DIRECTORY
The --info command shows:
Directory Auto-Derivation:
If SOURCE is a directory, zipbundler automatically looks for {dirname}/{dirname}.pyz in that directory. This is convenient for the common pattern where your source and built archive share the same parent directory name.
Examples:
# Display info from a specific archive file
zipbundler --info dist/myapp.pyz
# Display info using directory auto-derivation
# Looks for: myapp/myapp.pyz
zipbundler --info myapp
--compat FlagEnable compatibility mode for Python zipapp. This flag is reserved for future strict Python zipapp compatibility and ensures your builds will remain compatible with stdlib zipapp behavior in future versions.
Current Status:
Recommendation:
Use --compat if you require compatibility with Python’s stdlib zipapp module. This ensures your builds won’t break if we add strict compatibility mode features in the future.
Example:
# Build with compatibility mode enabled
zipbundler src/myapp -o app.pyz --compat
# Works with all other options
zipbundler src/myapp -o app.pyz -p "/usr/bin/env python3" -m "myapp:main" --compat
zipbundler buildBuild a zip file from the current directory or configuration file.
zipbundler build [OPTIONS]
Options:
-c, --config PATH: Path to configuration file (default: .zipbundler.jsonc)-i, --include PATHS: Override include paths from config. Format: path or path:dest--add-include PATHS: Additional include paths to append to config includes (CLI only). Format: path or path:dest-e, --exclude PATTERNS: Override exclude patterns from config--add-exclude PATTERNS: Additional exclude patterns to append to config excludes (CLI only)-o, --output PATH: Override output path from config--input PATH, --in PATH: Use an existing zipapp as the starting point. Can be a file path or directory. When a directory is given, zipbundler resolves the zip file name using the output filename-m, --main ENTRY_POINT: Override entry point from config-p, --shebang PYTHON: Override shebang from config--no-shebang: Disable shebang insertion--gitignore: Respect .gitignore patterns when selecting files (default)--no-gitignore: Ignore .gitignore and include all files-c, --compress: Compress files with deflate method--no-compress: Disable compression--compression-level LEVEL: Compression level 0-9 (only with –compress)--no-main-guard: Disable main guard insertion--disable-build-timestamp: Disable build timestamps for deterministic builds
(uses placeholder in PKG-INFO metadata)--dry-run: Preview what would be bundled without creating zip-f, --force: Force rebuild even if up-to-date--strict: Fail on configuration warnings-v, --verbose: Increase verbosity-q, --quiet: Reduce outputInclude Path Format:
path: Include directory/file, destination derived from source structurepath:dest: Include directory/file at custom destination in zipDestinations in the zip are relative paths. For example:
config.json:etc/config.json → file at root of zip: etc/config.jsonREADME.md:docs/README.md → file at root of zip: docs/README.mdsrc/lib → includes all files from src/lib directoryExamples:
# Build using default config
zipbundler build
# Build with custom config
zipbundler build --config custom.jsonc
# Append additional directories to config packages
zipbundler build --add-include extra/lib
# Append multiple items with custom destinations
zipbundler build \
--add-include config.json:etc/config.json \
--add-include README.md:docs/README.md
# Override includes (replace config)
zipbundler build --include "src/pkg1/**/*.py" "src/pkg2/**/*.py"
# Preview without building
zipbundler build --dry-run
# Build with compression
zipbundler build --compress --compression-level 9
# Force rebuild
zipbundler build --force
# Ignore .gitignore patterns (include all files)
zipbundler build --no-gitignore
# Respect .gitignore (default behavior)
zipbundler build --gitignore
# Append new packages to an existing zipapp
zipbundler build --input dist/app.pyz --force
# Update packages in an existing zipapp using a directory path
zipbundler build --input dist --force
# Append additional files to existing zipapp
zipbundler build --input existing.pyz --add-include new_module.py --force
zipbundler initCreate a default configuration file.
zipbundler init [OPTIONS]
Options:
-f, --force: Overwrite existing config file-o, --output PATH: Output file path (default: .zipbundler.jsonc)Examples:
# Create default config
zipbundler init
# Create with custom name
zipbundler init --output my-config.jsonc
# Overwrite existing
zipbundler init --force
zipbundler listList packages and files that would be included in the bundle.
zipbundler list [OPTIONS]
Options:
-c, --config PATH: Path to configuration file--tree: Show as directory tree--count: Show file count onlyExamples:
# List all files
zipbundler list
# Show as tree
zipbundler list --tree
# Just count
zipbundler list --count
zipbundler validateValidate a configuration file.
zipbundler validate [OPTIONS]
Options:
-c, --config PATH: Path to configuration file (default: .zipbundler.jsonc)--strict: Fail on warningsExamples:
# Validate default config
zipbundler validate
# Validate custom config
zipbundler validate --config custom.jsonc
# Strict validation
zipbundler validate --strict
zipbundler watchWatch for file changes and rebuild automatically.
zipbundler watch [OPTIONS]
Options:
-c, --config PATH: Path to configuration file--interval SECONDS: Watch interval in seconds (default: 1.0)--debounce SECONDS: Debounce time before rebuild (default: 0.5)Examples:
# Watch with default settings
zipbundler watch
# Watch with custom interval
zipbundler watch --interval 2.0
These options apply to all commands:
-h, --help: Show help message--version: Show version information--log-level LEVEL: Set log level (DEBUG, INFO, WARNING, ERROR)0: Success1: General error2: Configuration error3: Build error# Initialize config
zipbundler init
# Validate config
zipbundler validate
# Preview what will be bundled
zipbundler list
# Build the zip
zipbundler build
# Watch for changes
zipbundler watch
# Build with multiple package sources
zipbundler build \
--packages "src/pkg1,src/pkg2,installed_pkg" \
--exclude "**/tests/**,**/docs/**" \
--output dist/combined.zip
# Build executable zip
zipbundler build \
--entry-point "myapp.__main__:main" \
--output dist/myapp.zip
# Dry run to check configuration
zipbundler build --dry-run --verbose
# Build with deterministic timestamps for reproducible builds
zipbundler build --disable-build-timestamp
# Build with deterministic timestamps via environment variable
DISABLE_BUILD_TIMESTAMP=true zipbundler build
# Update existing zipapp with new packages
zipbundler build --input dist/app.pyz --force
# Incremental builds: append new modules to existing zipapp
zipbundler build --input existing.pyz --add-include src/new_module.py --force
--inputThe --input flag allows you to start from an existing zipapp and update it with new or modified packages:
# Initial build
zipbundler build -o dist/app.pyz
# Add new packages to the existing zipapp
zipbundler build --input dist/app.pyz --force
# The new build will:
# - Preserve all files from the input archive that aren't being updated
# - Update any packages specified in the current build
# - Replace PKG-INFO and __main__.py if new metadata or entry point is provided
# - Preserve other metadata files (if any)
Use Cases: