[Python-Dev] New and Improved Import Hooks

Steve Holden sholden@holdenweb.com
Thu, 5 Dec 2002 16:28:25 -0500


[MvL]
> >> Why not "copy" importing_modules_from_dlls(pyds) mechanism?
> >>What do you mean by that? What is "importing_modules_from_dlls"?
>
[Wiktor]
> >Should be "importing_module_from_dlls".
>
> I still don't understand. Is that some feature of Python?
>
I think Wiktor is referring to extensions, which under Windows are often
provided as .pyd DLLs.

> >>If you mean "one .pyd file is one Python module", then this approach
> >>won't work for .zip files:People want many .py modules in a single
> .zip
> >>file.
>
> >It will work if handled by the zip importer.
>
> How will the zip importer know what zipfile to read?
>
> If I have "python23.zip", and do
>
> import httplib
>
> what mechanism will extract httplib.py from python23.zip?
>
> > from MyArchive_with_many_modules import MyModule
>
> So you could only zip entire packages? This is insufficient.
>
I agree. What I'd like to see is the ability to replace a directory on
sys.path by a reference to a zipped copy, including any subdirectories, and
have all imports work just as they did before (whether they be extensions or
pure Python modules].

A quick look at my own code base, admittedly puny, reveals no statements
that would break were non-strings to be added to sys.path. Is there some way
to trap assignments to sys.path so a warning could be issued if sufficiently
un-stringy elements were discovered in it? Clearly it isn't enough to trap
assignment to and insertion of elements if breakage is to be totaly avoided.
We  have to know when the name is assigned-to as well.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------