virtualenv -p python3 venv
source ./venv/bin/activate
pip install Flask gunicornmkdir app
cd app
pip freeze > requirements.txt
pip install -t . -r requirements.txt
rm -rf ./__pycache__ ./*.dist-infocp -r ../flaskr .
cd ..python3 -m zipapp app -m 'gunicorn.app.wsgiapp:run' -p '/usr/bin/env python3'You get an executable .pyz archive with all dependencies bundled inside.
ls -lh app.pyz-rwxr--r-- 1 user user 4.0M Dec 18 09:38 app.pyz
file app.pyzapp.pyz: a /usr/bin/env python3 script executable (binary data)
./app.pyz flaskr:app[2017-12-18 09:38:35 +0200] [39081] [INFO] Starting gunicorn 19.7.1
[2017-12-18 09:38:35 +0200] [39081] [INFO] Listening at: http://127.0.0.1:8000 (39081)
[2017-12-18 09:38:35 +0200] [39081] [INFO] Using worker: sync
[2017-12-18 09:38:35 +0200] [39084] [INFO] Booting worker with pid: 39084