[Distutils] namespace_packages
Phillip J. Eby
pje at telecommunity.com
Wed Jan 18 21:08:36 CET 2006
At 12:51 PM 01/18/2006 -0600, Robert Kern wrote:
>Charlie Moad wrote:
> > Following the instruction for setuptools, I am trying to make
> > matplotlib and basemap (a mpl toolkit) share the namespace
> > "matplotlib/toolkits". I can build and install the eggs no problems.
> > "matplotlib/toolkits" is in both's "EGG-INFO/namespace_packages.txt"
> > files. I have added __init__.py files with
> > "__import__('pkg_resources').declare_namespace(__name__)" in both the
> > mpl and basemap matplotlib/toolkits folders. Basically I have done a
> > ton of playing around and "from matplotlib.toolkits import basemap"
> > will not work. It is always limited to the scope of the matplotlib
> > egg which it is hitting first. Are the docs not reflective of the
> > 0.6a9 release? Any help is greatly appreciated.
>
>That approach (adding the declare_namespace() calls to __init__.py files)
>should
>only be necessary when the __init__.py files contain actual code that needs to
>be executed.
Namespace packages will *require* declare_namespace() in __init__.py as of
0.7. Currently, there is a warning if you do not include it, because it
will absolutely be required in 0.7. The problem with the earlier approach
of leaving it out is that namespace packages were only being activated when
pkg_resources was imported, and *all* namespace packages on sys.path were
being immediately activated. These things are both somewhat problematic,
so in 0.7 the declare_namespace() approach will fix them. For the
remainder of 0.6, the old behavior remains, but there is a warning so that
everybody will add a declare_namespace() by the time 0.7 releases start
coming out.
More information about the Distutils-SIG
mailing list