Distributing python applications as a zip file

Burak Arslan burak.arslan at arskom.com.tr
Wed Jul 23 14:23:10 CEST 2014


On 07/23/14 07:23, Steven D'Aprano wrote:
> A little known feature of Python: you can wrap your Python application in 
> a zip file and distribute it as a single file. The trick to make it 
> runnable is to put your main function inside a file called __main__.py 
> inside the zip file. Here's a basic example:
>
> steve at runes:~$ cat __main__.py 
> print("NOBODY expects the Spanish Inquisition!!!")
>
> steve at runes:~$ zip appl __main__.py 
>   adding: __main__.py (stored 0%)
> steve at runes:~$ rm __main__.py 
> steve at runes:~$ python appl.zip 
> NOBODY expects the Spanish Inquisition!!!
>
>

does it support package_data? or more specifically, does
pkg_resources.resource_* detect that the script is running from a zip
file and adjust accordingly?



More information about the Python-list mailing list