Am 20.08.2013 18:22, schrieb Nick Coghlan:
On 20 Aug 2013 09:18, "Thomas Heller" <[email protected]
<mailto:[email protected]>> wrote:
>
> Am 20.08.2013 15:42, schrieb Nick Coghlan:
>
>> Importing C extensions requires extracting them to a temp directory and
>> loading them from there. Trivial in Python, a pain in C. zipimport is
>> currently still written in C.
>
>
> So what - zipimport is a builtin module (on Windows at least).
Huh? That's irrelevant to the fact that doing the tempdir creation, file
extraction and subsequent import entirely in C code would be painfully
tedious.
Ok, now I understand. But the zipfile could contain a loader-module
for each extension which does something like this (this example extracts
and loads 'bz2.pyd'):
def __load():
import imp, os
path = os.path.join(__loader__.archive, "--EXTENSIONS--", 'bz2.pyd')
data = __loader__.get_data(path)
dstpath = os.path.join(TEMPDIR, 'bz2.pyd')
with open(dstpath, "wb") as dll:
dll.write(data)
imp.load_dynamic(__name__, dstpath)
__load()
del __load
(py2exe for Python 3, which is work in progress, uses this approach)
Thomas
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig