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

Bradley M. Froehle brad.froehle at gmail.com
Wed Mar 27 22:19:39 CET 2013


On Wed, Mar 27, 2013 at 1:13 PM, Amaury Forgeot d'Arc <amauryfa at gmail.com>wrote:

> 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.
>

I implemented just such a path hook ---- zipimporter plus the magic
required for C extensions --- as a challenge to myself to learn more about
the Python import mechanisms.

See https://github.com/bfroehle/pydzipimport.

Cheers,
Brad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130327/3c4baf7b/attachment.html>


More information about the Python-Dev mailing list