[Python-Dev] New relative import issue

Guido van Rossum guido at python.org
Fri Sep 22 00:28:43 CEST 2006

On 9/21/06, Paul Moore <p.f.moore at gmail.com> wrote:
> On 9/21/06, Guido van Rossum <guido at python.org> wrote:
> > Isn't the main problem how to specify a bunch of these in the
> > environment? Or can this be done through .pkg files? Those aren't
> > cheap either though -- it would be best if the work was only done when
> > the package is actually needed.
> Hmm, I wasn't thinking of the environment. I pretty much never use
> PYTHONPATH, so I tend to forget about that aspect.

As Phillip understood, I meant the environment to include the
filesystem (and on Windows, the registry -- in fact, Python on Windows
*has* exactly such a mechanism in the registry, although I believe
it's rarely used these days -- it was done by Mark Hammond to support
COM servers I believe.)

> I was assuming an
> importer object with a "register(package_name, filesystem_path)"
> method. Then register the packages you want in your code, or in
> site.py.

Neither is an acceptable method for an installer tool (e.g. eggs) to
register new packages. it needs to be some kind of data file or set of
data files.

> But yes, you'd need to consider the environment. Possibly just have an
> initialisation function called at load time (I'm assuming the new hook
> is defined in a system module of some sort - I mean when that system
> module is loaded) which parses an environment variable and issues a
> set of register() calls.

os.environ is useless because there's no way for a package installer
to set it for all users.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list