[Distutils] zip imports ftw

Daniel Holth dholth at gmail.com
Sun Sep 16 14:07:55 CEST 2012


Of course the major potentially non obvious caveats are that a lot of python code doesn't use the API to load data from the importer path, instead using __file__ and assuming everything is one, and that sometimes (shared libraries) the system can't load it unless its a real file.

Daniel Holth

On Sep 15, 2012, at 11:44 PM, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:

> On Sat, Sep 15, 2012 at 8:19 PM, Daniel Holth <dholth at gmail.com> wrote:
>> I'd like to take this moment to note how awesome importing from
>> zipfile is. Did you know you can execute a zip file with Python, and
>> if it has a __main__.py in the root it will be executed, with the
>> zipfile's contents on the PYTHONPATH?
> 
> I've known this, but can you say a little about the caveats (e.g. why
> you wouldn't always want to store your packages as zip files)?  For
> example, IIRC you can't really use __file__ from within such modules.
> 
> --Chris


More information about the Distutils-SIG mailing list