Differences between revisions 8 and 9
Revision 8 as of 2005-01-04 20:53:07
Size: 1737
Editor: www
Revision 9 as of 2008-07-08 11:27:43
Size: 1745
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
Bauch's [http://www.joachim-bauch.de/tutorials/load_dll_memory.html MemoryModule] library. This library emulates the win32 api Bauch's [[http://www.joachim-bauch.de/tutorials/load_dll_memory.html|MemoryModule]] library. This library emulates the win32 api
Line 42: Line 42:
Sourcecode [http://starship.python.net/crew/theller/memimporter-0.0.1.zip memimporter-0.0.1.zip] Sourcecode [[http://starship.python.net/crew/theller/memimporter-0.0.1.zip|memimporter-0.0.1.zip]]
Line 44: Line 44:
Installer for Python 2.3 [http://starship.python.net/crew/theller/memimporter-0.0.1.win32-py2.3.exe memimporter-0.0.1-win32.py2.3.exe] Installer for Python 2.3 [[http://starship.python.net/crew/theller/memimporter-0.0.1.win32-py2.3.exe|memimporter-0.0.1-win32.py2.3.exe]]
Line 46: Line 46:
Installer for Python 2.4 [http://starship.python.net/crew/theller/memimporter-0.0.1.win32-py2.4.exe memimporter-0.0.1-win32.py2.4.exe] Installer for Python 2.4 [[http://starship.python.net/crew/theller/memimporter-0.0.1.win32-py2.4.exe|memimporter-0.0.1-win32.py2.4.exe]]


zipextimporter.py contains the ZipExtImporter class which allows to load Python binary extension modules contained in a zip.archive, without unpacking them to the file system.

Call the zipextimporter.install() function to install the import hook, add a zip-file containing .pyd or .dll extension modules to sys.path, and import them.

It contains a _memimporter.pyd extension which uses code from Joachim Bauch's MemoryModule library. This library emulates the win32 api function LoadLibrary.


LGPL (because that's what MemoryModule uses).

Sample usage

>>> import zipextimporter
>>> zipextimporter.install()
>>> import sys
>>> sys.path.append("lib.zip")
>>> import _socket
>>> _socket.__file__
>>> _socket.__loader__
<ZipExtensionImporter at a74480>


reload() on already imported extension modules does not work correctly: It happily loads the extension a second time.

zipextimporter doesn't yet work for extensions in packages, but I have a fix for that.


Sourcecode memimporter-0.0.1.zip

Installer for Python 2.3 memimporter-0.0.1-win32.py2.3.exe

Installer for Python 2.4 memimporter-0.0.1-win32.py2.4.exe

Comments, Feedback

Feedback appreciated. Log in to this wiki (click to UserPreferences link), and enter your comments here.

Hacks/ZipExtImporter (last edited 2008-07-08 11:27:43 by localhost)