[Python-Dev] Another approach for the import mechanism

Gustavo Niemeyer niemeyer@conectiva.com
Thu, 5 Dec 2002 20:31:37 -0200


> > What's your opinion about that?
> 
> Who's going to call sys.register_importer()?

Sorry, but I'll answer your question with another question:

Who's going to notify to the importer mechanism that zip importers
are available, in the current implementation?

> What does "current iterated path" mean?

for path in sys.path:
	default_importer(path)
	alternative_importer(path)

> How do I create a ZIP-only distribution?

Include __init__.zip in /usr/lib/python2.2.

> Do I need to restructure my code to use custom importers, or am
> I missing something?

Why would you need to?

> If I want to ship multiple ZIP archives, do I really have to name each
> one of them __init__.zip and place each one in a different directory?

It depends on what your zip archives are. If you want to include their
content as "top level" modules (as the standard library), yes. If they
are packages by themselves (like the email package), no.

> Have you tried Just's patch?

Do you agree that this is a different approach?

> What problem does your solution solve that his code doesn't already
> handle?

- Avoids including zip files in the path.

- Allows one to have zip packages inside other packages.

- Allows me to ship a package inside a zip file, without asking
  the user to change his path.

- Allows me to compress a single file (foobar.py.bz2).

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]