[Python-Dev] Safely importing zip files with C extensions

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Mar 27 21:13:27 CET 2013


2013/3/27 Vinay Sajip <vinay_sajip at yahoo.co.uk>

> When you mount a wheel, its absolute path name is added to
> sys.path, allowing the Python code in it to be imported.
>

Better: just put the wheel path to sys.path
    sys.path.append('/tmp/simplejson-3.1.2-cp27-none-linux_x86_64.whl')
and let a sys.path_hook entry do the job.

Such a WheelImporter could even inherit from zipimporter, plus the magic
required for C extensions.

It avoids the mount/nomount methods, only the usual sys.path operations are
necessary from the user.

-- 
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130327/61141a0e/attachment.html>


More information about the Python-Dev mailing list