[Python-Dev] Relative Package Imports

Jean-Claude Wippler jcw@equi4.com
Mon, 13 Sep 1999 18:23:35 +0200


"M.-A. Lemburg" wrote:
> Gordon McMillan wrote:
> > Jim Fulton wrote:
[deeply nested snippety snip]
> >
> > This would motivate me to strangle the author of NiftyDB. He
> > should say "This requires Marc-Andre's mx package", [...]

Yes.

> The mx package installed in product dir won't be visible to outside
> scripts: it is self-contained and only works in the context of Zope.

But why shouldn't it be visible?  The only approach which will not
self-destruct IMO, is to segment on source-of-origin.  Your package in
your namespace, Gordon's in his, and Jim's in yet another.  Given that
there is no ordering relationship, that means three areas next to each
other.  If Jim takes M-A's package and modifies it, then that would be a
reason to put M-A's-modified-by-Jim-package within Jim's area.

> Currently, only the top-level installation of the mx package
> will work and this of course introduces other problems like
> version control, e.g. the NiftyDB product (relying on mx 1.9)
> may not support version 2.0 of mx which the sysadmin installed
> at top-level. There would be no way (apart from patching NiftyDB)
> to get back to a working setup.

Which points to a solution in a completely different direction: version
numbers in package directories, like GNU and Tcl do, to name two.

> [...] have it enabled and available per default, so that writing
> self-contained packages becomes a standard in the Python world.

A noble goal.

Now this may be a silly question, but what's the issue here?  I'm used
to writing things which sort of look like this:
	import myGoobledygook
	utils = myGoobledygook
	print utils.fun(123)
Couldn't this be applied here as well:
	mxDT = aCoolImporter("Marc-Andre's latest date/time utilities")
In other words: figure out a way to get at the proper modules, then use
an alias in your own code to stay away from naming/access dependencies?

And if a parent wants to tell a submodule how to find it, can't it just
set a variable at module level in that submodule, to reach it?

Aliases, bookmarks, symlinks, shortcuts, env vars, globals, registries,
DNS or LDAP servers, FS mount points - it's all the same issue.

-- Jean-Claude