Import binary extensions from zipfiles, windows only
PeterMayne at ap.spherion.com
Wed Jan 5 20:28:29 EST 2005
Thomas Heller wrote:
> zipextimporter, as published, doesn't handle extensions in packages.
> The patch I attached at the end, may fix this - I tested it with PIL.
Thanks, that works fine.
However, ZopeX3 itself still won't run. As part of the startup, it
attempts to load some files relative to imported classes. Since the
path dives into a zip file, opening a file such as
file://///C|/tmp/zope.zip/zope/app/server/schema.xml doesn't work.
Patching things up to avoid this just leads deeper into the mire, so it
looks like this avenue is closed.
Things would probably be easier if Python had something like Java's
Class.getResourceAsStream(), where a resource is found by the class
loader. This means that is doesn't matter if the class came from a
directory, a JAR file, or a network: if the class loader could load the
class, it could also load the resource from the same place. The
__loader__ attribute from PEP 302 seems to be the equivalent, but the
standard importer doesn't provide it.
maynp at nessus:~> python
Python 2.3.4 (#1, Jul 31 2004, 11:22:19)
[GCC 3.3.1 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute '__loader__'
More information about the Python-list