3 ms·
I'm always on the lookout for ways of packaging Python programs/script-piles into single-file executables, so thank you for posting this! The GitHub README say
by MikeTheGreat 2y ago
I'm always on the lookout for ways of packaging Python programs/script-piles into single-file executables, so thank you for posting this!
The GitHub README says it builds on the Python .ZIP App format (PEP441), which in turns says you can put your app in a .ZIP file and Python will run it as an app.
I think I went this route with PyInstaller's one-file output option. But I found it to be too slow because (1) my app was a CLI app and I needed it to start, run, and end quickly, (2) I imported something from Django because it was useful (which ballooned the size), and (3) the single-file .ZIP needed to be extracted into a temporary directory, run, and then deleted every time (!!!).
Does anyone know how Pex / PEP441 deals with this? Is the extract-run-delete thing normal/standard? Is there a way to cache the extracted app?
- tylerhou 2y agoMy guess is that without operating system support or equivalent, there is not an easy way to avoid extracting the zip file. (You could patch syscalls in the Python interpreter to read from the zip file for certain paths, but that might be hacky.) I did find https://github.com/google/mount-zip https://github.com/google/mount-zip which might be useful, but you would likely have to still mount the zip manually. However, you don’t have to worry as much about cleaning up after yourself.
- redleader55 2y agoYou might find interesting looking at XAR[0] which works by mounting a squashfs filesystem of the "archive", instead of using a zip file. The squashfs is mounted/unmounted "lazily" meaning if you run it a few times in a row it will only mount it one time. [0] -https://github.com/facebookincubator/xar https://github.com/facebookincubator/xar