Skip to content

Instantly share code, notes, and snippets.

@helix84
Forked from asimjalis/python-zip.md
Last active April 5, 2020 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helix84/aa1f8cb6cf7d707a8b49c464307e819d to your computer and use it in GitHub Desktop.
Save helix84/aa1f8cb6cf7d707a8b49c464307e819d to your computer and use it in GitHub Desktop.
How to deploy a Python application as a zip file

How to deploy a Python application as a zip file

by Asim Jalis, MetaProse.com

Create a file __main__.py containing:

print "Hello world from Python"

Zip up the Python files (in this case just this one file) into app.zip by typing:

zip app.zip *

The next step adds a shebang to the zip file and saves it as app—at this point the file app is a zip file containing all your Python sources.

echo '#!/usr/bin/env python' | cat - app.zip > app
chmod 755 app

That’s it. The file app is now have a zipped Python application that is ready to deploy as a single file.

You can run app either using a Python interpreter as:

python app

Or you can run it directly from the command line:

./app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment