✅ Serverless / Fargate / Lambda
Upload the zip directly. Cold starts are faster because there’s no dependency resolution.
✅ Edge devices & embedded Linux
Your Python runtime is already there. Just copy the zip over a serial connection or SSH.
✅ CI/CD pipelines
Build once, test the zip, promote the same artifact to prod. No pip install during deployment. py3esourcezip
✅ Air-gapped environments
Pre-download all wheels, build the zip on a build machine, and transfer it via USB.
The zipfile module also supports more advanced features, such as: ✅ Serverless / Fargate / Lambda
Upload the zip directly
import zipfile
# Open a zip file in append mode
with zipfile.ZipFile('example.zip', 'a') as zip_file:
# Add a file to the zip
zip_file.write('newfile.txt')
# Open a zip file and read a file
with zipfile.ZipFile('example.zip', 'r') as zip_file:
with zip_file.open('file1.txt', 'r') as file:
content = file.read()
print(content)
cd my_package zip -r ../my_script.zip . cd ..
unzip -l application.py3esourcezip
Sample output:
Archive: application.py3esourcezip
Length Date Time Name
--------- ---------- ----- ----
1234 2025-01-15 10:23 __main__.py
456 2025-01-15 10:23 config.yaml
7890 2025-01-15 10:23 utils/helpers.py
echo "from mypackage.main import run; run()" > $WORK_DIR/main.py import zipfile # Open a zip file in append mode with zipfile