4 ms·
You don't have to. Use zipapps, this allows you to create a project with as many deps as you want, but use it as if it was a single python module. It's an offi
by BiteCode_dev 6y ago
You don't have to. Use zipapps, this allows you to create a project with as many deps as you want, but use it as if it was a single python module.
It's an official feature (https://docs.python.org/fr/3/library/zipapp.html https://docs.python.org/fr/3/library/zipapp.html) that lets Python execute an entire project bundled into a zip file.
If you don't want to create it by hand, use shiv: https://pypi.org/project/shiv/ https://pypi.org/project/shiv/
It's the best of both worlds.
- dahfizz 6y agoThat's really cool! I can't believe I've never come across this, thanks for sharing!
- BiteCode_dev 6y agoYou are not alone. __main__.py in a zip has been supported litterally since Python 2.6 but very few people knew about it. Eventually in 3.5, the zipapp module has been released to make the feature more discoverable, but again it has been mostly ignored. I think the reason is that something like shiv was missing: it streamlines the process, shows a finish product instead of just telling people "all the thing they can do", and the automatic unzipping solved plenty of problems that you had with alternative like Pex, espacially on windows or with static resources. So now you have it. Spread the word.