[ANN] [Hack] Import binary extensions from zipfiles, windows only

Thomas Heller theller at python.net
Thu Dec 16 11:02:40 CET 2004

Warning: experimental code!


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 uses the _memimporter extension which uses code from Joachim
Bauch's MemoryModule library.  This library emulates the win32 api
function LoadLibrary.

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.




More information about the Python-announce-list mailing list