[Distutils] Setuptools: omit namespace package directories?

Thomas Lotze thomas at thomas-lotze.de
Fri Feb 9 23:01:20 CET 2007


Am Fri, 09 Feb 2007 16:16:45 -0500 schrieb Phillip J. Eby:

> As far as I can see, then, there is no
> way to support crazy package_dirs in combination with namespace packages,
> without automatically creating a bunch of directories and __init__.py
> files, along with some other crazy hacks.  So the idea is probably a dead
> duck.

Not necessarily. If I get all of this right, then namespace packages work
by creating a bunch of module objects in sys.modules which then take care
of finding the right place to import any given subpackage from. So what is
needed is to get some code executed that does the Right Thing when first
trying to import a package or module that resides inside a namespace.

If the egg promise is that putting an egg on sys.path suffices for making
it available to Python, this precludes relying on .pth files in any way
for doing something other than modifying sys.path itself, right? After
all, the egg could be added to sys.path after .pth files have been
evaluated - which I understand is the approach buildout takes.

The next chance to get code executed is when the top-level namespace's
__init__.py is imported. Thus there absolutely must exist a directory for
the top-level namespace inside the source tree. But - what prevents the
__init__.py file in this directory from setting up any intermediate
namespaces in sys.modules and causing the real package to be looked for in
some convenient place that avoids directory jumping in the source tree?

-- 
Viele Grüße,
Thomas




More information about the Distutils-SIG mailing list