[Distutils] Re: new import mechanism and a "small" distribution

Greg Stein gstein@lyra.org
Mon, 01 Feb 1999 06:39:17 -0800


Gordon McMillan wrote:
> 
> [Greg puts code where his mouth is]
> 
> > A while back, Mark Hammond brought up a "new import architecture"
> > proposal after some discussion with Jack Jansen and Guido. I
> > responded in my usual diplomatic style and said "feh. the two-step
> > import style is bunk."
> 
> [snip...]
> 
> This is outrageously cool!
> 
> It appears that you're aiming for a rewrite of import.c (and
> friends) and giving new meaing to "sys.path". (I love it - Java says
> "it can be a directory or a zip file" and Greg says "why stop there?
> It can be anything at all" - hee hee).

Yup :-)

Last month, I even argued that the import mechanism could simply be
shifted entirely to Python, too, since the overhead of interpreted
Python code is minimal next to the parsing, execution, and/or I/O
involved with importing. hehe...

> What is enabling this magic in this prototype? We pick up your
> site.py automatically, but is your python.exe doing something in
> between Py_Initialize and Py_Main? Or is this all based on making a
> chain out of __builtin__.__import__?

If python.exe doesn't find its registry settings, then it assumes a
default sys.path (which includes the current directory). Using that, it
loads exceptions.py and then site.py. Once site.py loads, then I install
the custom import hook so that all future imports will be yanked from
py15.pyl. The builtin modules aren't in there, of course, so those fall
down the chain to the builtin importer.

Cheers,
-g

--
Greg Stein, http://www.lyra.org/