At 07:02 PM 7/21/2009 -0500, Dave Peterson wrote:
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.

It won't do either unless the name of the enclosing zipfile ends with .egg; in such a case all you can use is resource_string or resource_stream.


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?

It would probably be better to extract tvtk_classes.zip to a directory of the same name, so that instead of having nested zipfiles, there's only one level of zipping, and you'll just be able to put the zipped subdirectory on sys.path. (Note that you can put a subdirectory of a zipfile on sys.path, and it'll still work. It's just that the subdirectory has to be a directory inside the zipfile, not another zipfile inside the zipfile.)

_______________________________________________
Distutils-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to