zipimport (.pyd & .so) files.

Thomas Jollans thomas at jollans.com
Fri Jul 9 13:58:10 EDT 2010


On 07/09/2010 06:36 PM, King wrote:
> Hi,
> 
> The 'zipimport' modules can only import (.py & .pyc) files from a zip
> file and doesn't support importing .pyd & .so files. Recently I was
> examining the code of Py2Exe (python package deployment tool) and I
> have found that it is using a module 'zipextimporter' that can import
> dlls(.pyd) modules from a zip file.
> It is based on the concept of loading library form memory. You can
> find out more about here:
> http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/

I just had a quick look at that article (I hadn't before). It's probably
possible to do something similar on other systems: In principle, you can
know the layout of an .so, and then manually load it. But, basically,
don't. While supporting Linux itself might not be too difficult (you can
use the libdl (or kernel?) sources as a reference, I expect), but
supporting multiple UNIX variants is almost certainly very, very difficult.

Maybe there are some actual experts around with a different view, but
I'd recommend, to load object code not directly accessible via the file
system, put it in the file system!

> 
> It's strictly for windows platform. I would like to know from expert
> python users and linux programmers, how we can achieve similar
> functionality on linux platform? I do have limited c/c++ skill sets
> but I would love to give a try.
> 
> Cheers
> 
> Prashant
> 




More information about the Python-list mailing list