Convert a script with inline script metadata into an executable Python zip archive.
Find a file
Tobias Bölz 9930898c68
All checks were successful
Release / create-pyz (release) Successful in 22s
Version 0.2.0
2025-08-29 19:51:23 +02:00
.forgejo/workflows Version 0.2.0 2025-08-29 19:51:23 +02:00
.flake8 Initial commit 2025-08-01 18:46:26 +02:00
.gitignore Initial commit 2025-08-01 18:46:26 +02:00
CHANGELOG.md Version 0.2.0 2025-08-29 19:51:23 +02:00
poetry.lock Initial commit 2025-08-01 18:46:26 +02:00
pyproject.toml Version 0.2.0 2025-08-29 19:51:23 +02:00
README.md Version 0.2.0 2025-08-29 19:51:23 +02:00
script2pyz.py Add --extra-dependencies option 2025-08-29 19:38:23 +02:00

script2pyz

Convert a script with inline script metadata into an executable Python zip archive.

Requirements

  • Python >= 3.11

Usage

Download script2pyz.pyz from the releases page and run it with Python1:

$ python script2pyz.pyz --help
Usage: script2pyz.pyz [OPTIONS] SCRIPT_FILE

  Convert a script with inline script metadata into an executable Python zip
  archive.

Options:
  -o, --output FILE               Output file. Defaults to script file name
                                  with .pyz extension in working directory.
  -p, --python INTERPRETER        Add a #! line to the archive specifying
                                  interpreter as the command to run. Also, on
                                  POSIX, make the archive executable. The
                                  default is to write no #! line, and not make
                                  the file executable.
  -c, --compress                  Compress files with the deflate method,
                                  reducing the size of the output file. By
                                  default, files are stored uncompressed in
                                  the archive.
  --extra-dependencies REQUIREMENT_SPECIFIERS
                                  Add additional packages to the zip archive.
  -y, --yes                       Answer yes to all user prompts.
  -n, --no                        Answer no to all user prompts.
  --help                          Show this message and exit.

Limitations

  • The packages required by your script must be pure Python. Packages with C extension cannot be run from a zip file2.
  • Some packages without extensions will not work either. Keep in mind that barely any package will have been tested in this way.

Alternatives

License

This project is licensed under the MIT license.


  1. Alternatively, you can install script2pyz as a package or run script2pyz.py with pipx run. ↩︎

  2. See https://docs.python.org/3/library/zipapp.html#caveats. ↩︎