[Python-Dev] Safely importing zip files with C extensions (original) (raw)

Stefan Behnel stefan_ml at behnel.de
Wed Mar 27 21:34:19 CET 2013


Vinay Sajip, 27.03.2013 20:38:

>>> w = Wheel('/tmp/simplejson-3.1.2-cp27-none-linuxx8664.whl') >>> w.mount() >>> import simplejson.speedups >>> dir(simplejson.speedups) ['doc', 'file', 'loader', 'name', 'package', 'encodebasestringascii', 'makeencoder', 'makescanner', 'scanstring'] >>> simplejson.speedups.file '/home/vinay/.distlib/dylib-cache/simplejson/speedups.so'

I've always hated this setuptools misfeature of copying C extensions from an installed archive into a user directory, one for each user. At least during normal installation, they should be properly unpacked into normal shared library files in the file system.

Whether it then makes sense to special case one-shot trial imports like the above without installation is a bit of a different question, but I don't see a compelling reason for adding complexity here. It's not really an important use case.

Stefan



More information about the Python-Dev mailing list