Command-line tools#
One file#
The default single target writes one .py that contains a small importer and every bundled
module:
It needs only a Python interpreter and the standard library on the target machine. Code that
imports compiled third-party extensions can't live in a single file. Use tree or pyz, or
include pure-Python packages so they are bundled.
Zipapp#
pyz writes a zipapp with a shebang. Sources
inside the archive are registered with linecache, so warnings and tracebacks show code lines,
which plain zipapps do not.
Smaller still#
--minify drops comments and blank lines but keeps every remaining line at its original line
number. --strip-docstrings also removes docstrings, like python -OO. Only use it when nothing
reads __doc__: argparse and click help texts often do.