This PEP proposes to fix these problems by re-publicising the feature, defining the .pyz and .pyzw extensions as "Python ZIP Applications" and "Windowed Python ZIP Applications", and providing some simple tooling to manage the format.

This feature is not as popular as it should be mainly because it was not promoted as part of Python 2.6 , so that it is relatively unknown, but also because the Windows installer does not register a file extension (other than .py ) for this format of file, to associate with the launcher.

Python has had the ability to execute directories or ZIP-format archives as scripts since version 2.6 . When invoked with a zip file or directory as its first argument the interpreter adds that directory to sys.path and executes the __main__ module. These archives provide a great way to publish software that needs to be distributed as a single file script but is complex enough to need to be written as a collection of modules.

The terminology "Python Zip Application" will be the formal term used for a zip-format archive that contains Python code in a form that can be directly executed by Python (specifically, it must have a __main__.py file in the root directory of the archive). The extension .pyz will be formally associated with such files.

The Python 3.5 installer will associate .pyz and .pyzw "Python Zip Applications" with the platform launcher so they can be executed. A .pyz archive is a console application and a .pyzw archive is a windowed application, indicating whether the console should appear when running the app.

On Unix, it would be ideal if the .pyz extension and the name "Python Zip Application" were registered (in the mime types database?). However, such an association is out of scope for this PEP.

Python Zip applications can be prefixed with a #! line pointing to the correct Python interpreter and an optional explanation:

#!/usr/bin/env python3 # Python application packed with zipapp module (binary contents of archive)

On Unix, this allows the OS to run the file with the correct interpreter, via the standard "shebang" support. On Windows, the Python launcher implements shebang support.

However, it is always possible to execute a .pyz application by supplying the filename to the Python interpreter directly.

As background, ZIP archives are defined with a footer containing relative offsets from the end of the file. They remain valid when concatenated to the end of any other file. This feature is completely standard and is how self-extracting ZIP archives and the bdist_wininst installer format work.