Complete CLI Reference¶
This is a full reference of the project’s command line tools,
with the same information as you get from using the
It is generated from source code and thus always up to date.
Shiv is a command line utility for building fully self-contained Python zipapps as outlined in PEP 441, but with all their dependencies included!
shiv [OPTIONS] [PIP_ARGS]...
Show the version and exit.
The entry point to invoke (takes precedence over –console-script).
The console_script to invoke.
The path to the output file for shiv to create.
The python interpreter to set as the shebang (such as ‘/usr/bin/env python3’)
The path to an existing site-packages directory to copy into the zipapp.
Whether or not to compress your zip.
Whether or not to compile pyc files during initial bootstrap.
Add the contents of the zipapp to PYTHONPATH (for subprocesses).
Generate a reproducible zipapp by overwriting all files timestamps to a default value. Timestamp can be overwritten by SOURCE_DATE_EPOCH env variable. Note: If SOURCE_DATE_EPOCH is set, this option will be implicitly set to true.
If specified, this modifies the runtime of the zipapp to raise a RuntimeException if the source files (in ~/.shiv or SHIV_ROOT) have been modified. It’s recommended to use Python’s “–check-hash-based-pycs always” option with this feature.
Provide a path to a preamble script that is invoked by shiv’s runtime after bootstrapping the environment, but before invoking your entry point.
Override the ‘root’ path (default is ~/.shiv).
Choosing a Python Interpreter Path¶
A good overall interpreter path as passed into
If you want to make sure your code runs on the Python version you tested it on,
include the minor version (e.g.
… python3.6) – use what fits your circumstances best.
On Windows, the Python launcher
py knows how to handle shebangs using
so it’s overall the best choice if you target multiple platforms with a pure Python zipapp.
Also note that you can always fix the shebang during installation of a zipapp using this:
python3 -m zipapp -p '/usr/bin/env python3.7' -o ~/bin/foo foo.pyz