[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python, Be Bold!

Greg Ewing <greg.ewing at canterbury.ac.nz>:
> You can pass a zip file with a .pyz extension to the python
> interpreter and it will look for a __main__.py file and run
> it.

This discussion has been interesting, and I've now learned about zipapp.
This is really nice and will likely be a favorite distribution format
for Python applications.

My initial instinct would be to use zipapp as follows:

 * The starting point is a directory containing the Python source files,
   possibly with subdirectories. (A simple, two-file example:
   "myapp.py", "auxmod.py".)

   Be sure that "myapp.py" contains the boilerplate footer:

   if __name__ == '__main__':

 * Test that the program works:

   $ ./myapp.py

 * Generate the zipapp:

   $ python3 -m zipapp . -o ../myapp.pyz --main myapp:main \
       -p "/usr/bin/env python3"

 * Try it out:

   $ ../myapp.pyz