[Python-Dev] New relative import issue

Steve Holden steve at holdenweb.com
Fri Sep 22 06:38:24 CEST 2006

Paul Moore wrote:
> On 9/21/06, Guido van Rossum <guido at python.org> wrote:
>>I think one missing feature is a mechanism whereby you can say "THIS
>>package (gives top-level package name) lives HERE (gives filesystem
>>location of package)" without adding the parent of HERE to sys.path
>>for all module searches. I think Phillip Eby's egg system might
>>benefit from this.
> This is pretty easy to do with a custom importer on sys.meta_path.
> Getting the details right is a touch fiddly, but it's conceptually
> straightforward.
> Hmm, I might play with this - a set of PEP 302 importers to completely
> customise the import mechanism. The never-completed "phase 2" of the
> PEP included a reimplementation of the built in import mechanism as
> hooks. Is there any interest in this actually happening? I've been
> looking for an interesting coding project for a while (although I
> never have any free time...)
My interest in such a project would be in replacing a bunch of legacy C 
code with varying implementations of the import mechanism in pure Python 
strictly according to the dictats of PEP 302, using sys.path_hooks and 
sys.path (meta_path is for future consideration ;-).

Some readers may remember a lightning talk I gave at OSCON about three 
years ago. In that I discussed a database structure that allowed 
different implementations of modules to be loaded according to 
compatibility requirements established as a result of testing.

Although I now have a working database import mechanism based on PEP 302 
it's by no means obvious how that can be used exclusively (in other 
words, replacing the current import mechanism: the present 
implementation relies on an import of MySQLdb, which has many 
dependencies that clearly must be importable before the DB mechanism is 
in place). And I certainly haven't followed up by establishing the 
compatibility data that such an implementation would require.

Has anyone done any work on (for example) zip-only distributions?

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden

More information about the Python-Dev mailing list