[Python-Dev] zipimport & import hooks
Jack Jansen
Jack.Jansen@oratrix.com
Sat, 7 Dec 2002 01:17:43 +0100
On vrijdag, dec 6, 2002, at 13:52 Europe/Amsterdam, Fredrik Lundh wrote:
> Just van Rossum wrote:
>
>> It seems the majority doesn't like non-strings on sys.path, which to
>> me is
>> understandable, especially if you take PYTHONPATH into consideration.
>> Let's try
>> to focus on that.
>
> Has anyone presented any hard data, or are people just guessing? As
> far
> as I can tell, I'm the only one here who has posted fragile code from
> a real
> shipping product -- and I still believe it's a bogus argument.
There are 3 distinct types of problems in Mac/Lib.
1. macresource locates .rsrc files on sys.path. I think this is a
similar use case Fredrik presented: finding what is essentially a data
file on sys.path. This is going to be a real problem if everything is
packed into a zipfile.
2. buildtools loops over sys.path looking for a specific module (using
os.path calls). This is a problem, but these uses can be converted to
case (3).
3. buildtools (in another place) and bundlebuilder use imp.find_module
to find modules and then proceed to do things like use the resulting
pathname (like copying the file found). These will probably fail if
there are zipfiles on sys.path, but at least there is a chance of
fixing them. imp.find_module should return a recognizable magic cookie
in stead of the pathname for zipfiles (and, later, for any other
non-filesystem importers). I think we have to leave it at "magic
cookie" and declare this Somebody Else's Problem, every time I try to
think of functionality to put in the cookie I end up with something
resembling a complete virtual filesystem interface. As a partial fix
the file object returned by find_module could be an object that would
"work".
--
- Jack Jansen <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma
Goldman -