[Distutils] namespace_packages

Charlie Moad cwmoad at gmail.com
Fri Jan 20 18:41:00 CET 2006


On 1/20/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 11:20 AM 01/20/2006 -0500, Charlie Moad wrote:
> >On 1/19/06, Robert Kern <robert.kern at gmail.com> wrote:
> > > Charlie Moad wrote:
> > > > Well here are th cvs links to them.
> > > >
> > > >
> > http://cvs.sourceforge.net/viewcvs.py/matplotlib/matplotlib/setup.py?rev=1.143&view=auto
> > > >
> > http://cvs.sourceforge.net/viewcvs.py/matplotlib/toolkits/basemap/setup.py?rev=1.33&view=auto
> > > >
> > > > The matplotlib.toolkits module does not exist in the mpl cvs and it is
> > > > not in the setup.py file.  I have tried adding both.  In basemap
> > > > however, the matplotlib.toolkits module does exist and is listed in
> > > > the setup.py file.
> > >
> > > Both of these setup.py files are buggy. The packages list needs to have
> > entries
> > > in dotted form ("matplotlib.toolkits"), not filesystem form
> > > ("matplotlib/toolkits"). Correcting them, and adding an empty
> > > lib/matplotlib/toolkits/__init__.py to the matplotlib checkout allows me to
> > > build eggs with namespace_packages set appropriately.
> > >
> >
> >I finally got time to try this, and it didn't help much.  Changing all
> >the packages to dot notation works fine.  I have added the
> >toolkits/__init__.py file.  Setuptools warns about not having
> >declare_namespace in the init files.  I have added this:
> >
> >try:
> >     __import__('pkg_resources').declare_namespace(__name__)
> >     print __name__, __file__
> >except ImportError:
> >     pass # must not have setuptools
>
> Note that if you don't have pkg_resources, namespace packages simply won't
> work, so there's little point in the try/except.

I don't want an ImportError raised for people who don't have
setuptools, which is definitely a majority of mpl users.

> >to __init__.py in mpl's and basemap's matplotlib and
> >matplotlib.toolkits module, hence in 4 places.
> >Upon starting python I get this output:
> >
> >matplotlib
> >/usr/lib/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-i686.egg/matplotlib/__init__.pyc
> >matplotlib.toolkits
> >/usr/lib/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-i686.egg/matplotlib/toolkits/__init__.pyc
> >
> >So the basemap declarations are never being reached.  Where should I
> >go from here?
>
>
> Is the other egg you're looking for on sys.path?

Yes. /usr/lib/python2.4/site-packages/basemap-0.8-py2.4-linux-i686.egg
is in easy-install.pth.  I can import its top level modules, just not
the conflicting matplotlib.toolkits.basemap module.


More information about the Distutils-SIG mailing list