[Distutils] Possible to import from a zipfile retrieved from within an .egg using pkg_resource's ResourceManager API?

Dave Peterson dpeterson at enthought.com
Wed Jul 22 02:02:02 CEST 2009


Background:
The Mayavi project generates wrapper code around VTK during it's build 
process.  This gets bundled into a zip file called tvtk_classes.zip and 
included in a binary distribution.   Currently, we mark built eggs as 
non-zip-safe so that they get unpacked during installation, which makes 
it possible to find the zip file and add it directly to sys.path.  
However, this mechanism won't work when someone tries to distribute an 
app containing Mayavi by using py2app, py2exe, etc. because all of 
site-packages usually gets bundled in a single zip.

Problem:
I'm wondering if there is some way to use pkg_resources to retrieve a 
reference to the embedded zip file within py2app's generated 
site-packages.zip (or within an unpacked egg install) and somehow add 
that to sys.path?   The only obvious thing I see in pkg_resource's 
ResourceManager API docs is to extract the embedded zipfile via 
"resource_filename".  However, it isn't clear to me whether calling that 
will extract *everything* within the containing zip, or just unpack the 
requested resource itself.   The former could be a rather large 
performance hit in the case of py2app.  Does anyone have any feedback on 
the performance of using this resource_filename API?

Or is there a better way to do this?  Perhaps there is a way to force 
py2app/py2exe to avoid putting Mayavi within the site-packages zipfile?  
(Right now, I'm more concerned about the py2app usecase than I am the 
zip-within-an-egg usecase.)


Thanks in advance for any advice!


-- Dave




More information about the Distutils-SIG mailing list