Convert a script with inline script metadata into an executable Python zip archive.
				
			
		| 
				 | 
			||
|---|---|---|
| .forgejo/workflows | ||
| .flake8 | ||
| .gitignore | ||
| CHANGELOG.md | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| script2pyz.py | ||
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.
- 
Alternatively, you can install
script2pyzas a package or runscript2pyz.pywithpipx run. ↩︎ - 
See https://docs.python.org/3/library/zipapp.html#caveats. ↩︎