[Python-Dev] New relative import issue
Guido van Rossum
guido at python.org
Thu Sep 21 22:54:45 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:
> > 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.
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 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...)
There's a general desire to reimplement import entirely in Python for
more flexibility. I believe Brett Cannon is working on this.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list