3 ms·
I was not aware of zipapp ... but it's interesting to see it exists as a method for enabling python to run 'zipped packages' ... since python can already do tha
by tpoacher 2y ago
I was not aware of zipapp ... but it's interesting to see it exists as a method for enabling python to run 'zipped packages' ... since python can already do that by default with normal zipfiles, as long as the zipfile appears / is added to the python path (which is roughly analogous to how one can add .jar files to the classpath in java). E.g.:
export PYTHONPATH="package.zip"
python3 -m packagename
will work just fine.
(PS. I document this technique in one of my python-template projects: https://git.sr.ht/~tpapastylianou/python-self-contained-runnable-package-template https://git.sr.ht/~tpapastylianou/python-self-contained-runn...)
I suppose, if the intent is to package something in a manner that attempts to make it newbie-proof, then requiring a PYTHONPATH incantation before the python part might be one step too far ... but then again, one could argue the same about people not quite knowing what to do with a .pyz file and getting stuck.
- BiteCode_dev 2y agoCheckout shiv for turning even more zipapp goodness: https://shiv.readthedocs.io/en/latest/ https://shiv.readthedocs.io/en/latest/
- ttyprintk 2y agoshiv has two things over zipapp: A bootstrap boilerplate that allows the shiv to be able to run as an interpreter. I think zipapp can only be given code.interact as main. Unpacking wheels into ~/.shiv, which might be faster. I can’t remember if this permits running compiled C, which is not possible from within a zipapp.