look further down sys.path for extension module

vincent wehren vincent at visualtrans.de
Wed Oct 27 15:55:03 EDT 2004


Martin v. Löwis wrote:
> Vincent Wehren wrote:
> 
>> Is it possible to have Python look further down sys.path for a C
>> extension module when an ImportError is raised because of the "dynamic
>> module not implementing init function"?
> 
> 
> You could use the imp module to import zlib.pyd "manually". Then, when
> an "import zlib" occurs, it looks into sys.modules, finds that zlib is
> already there, and forgets about looking into sys.path.

This sounds like a viable option. We already have some special hooks to 
accomodate for using pywin32 from a network install so this would be 
something along those same lines.

 > Alternatively, you could rebuild zlib.pyd to be named pyzlib.pyd. You
> need to rebuild the code because you also need to rename the entry
> function, and the name of the module inside the module itself. You
> can then do
> 
> import pyzlib as zlib

Yes, quickly tried that, too. It still is registered in sys.modules as 
"pyzlib" - don't known if I expected that...


Thanks for your input!

--
Vincent Wehren



More information about the Python-list mailing list