When I have a python shared object file (.so
) in my sys.path, I can simply do :
import _ctypes
And it will import python2.7/lib-dynload/_ctypes.so
.
However, if I use a zipfile called tmp.zip
that contains :
Hello/_World.so
with world.so
containing a well formatted init_World
function, then :
Python 2.7.10 (default, Jun 1 2015, 18:05:38)
[GCC 4.9.2] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(0, 'tmp.zip')
>>> import _World
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
zipimport.ZipImportError: can't find module _World
I read it was impossible to load shared object files outside a filesystem in C.
Does this mean what I’m trying to achieve is impossible and that _World.so
should be extracted from the archive ?
I’m only interested about doing it directly with thezipimport
. I know there are other ways of doing it like extracting the archive manually and create files.