John Hunter wrote:
> Do we need namespace packages in toolkits?  I recently added gtktools
> and exceltools to toolkits, and got a very hard to debug error:
> 
> In [1]: import matplotlib
> 
> In [2]: matplotlib.__file__
> Out[2]: 
> '/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/__init__.pyc'
> 
> In [3]: matplotlib.rcParams['axes.axisbelow']
> Out[3]: False
> 
> In [4]: import matplotlib.toolkits.gtktools
> 
> In [5]: matplotlib.__file__
> Out[5]: 
> '/opt/app/g++lib6/python-2.4/lib/python2.4/site-packages/matplotlib/__init__.pyc'
> 
> In [6]: matplotlib.rcParams['axes.axisbelow']
> ------------------------------------------------------------
> Traceback (most recent call last):
>   File "<ipython console>", line 1, in ?
> KeyError: 'axes.axisbelow'
> 
> Notice that the matplotlib module which was previously imported got
> changed by the import of the toolkit which declared itself a namespace
> package.  Now this may be the result of mpl not using namespace
> packages correctly (eg matplotlib/__init__.py should be empty save for
> the namespace package or something like that)

Probably. In setuptools 0.7, they can have stuff in them, but all of them must
be identical. If you are using an unmodified matplotlib/__init__.py in the main
matplotlib package, then the "if 0:" is preventing the declaration of the
namespace package, and that may be contributing.

Also, neither matplotlib nor matplotlib.toolkits is named as a namespace_package
in matplotlib's setup.py, and both have to be. Similarly, basemap (for example)
only lists matplotlib.toolkits but not matplotlib.

> but I gotta tell ya,
> this looks just plain wrong.  Had I not known that namespace packages
> were funky like this, it could have taken me a long time to trace this
> bug.

Well, when you do exactly what you were told not to do, this is what happens.
Don't make me break out the "Doctor, it hurts when I do this!" bromide. If you
don't want to bother to learn to use namespace packages correctly, that's
perfectly fine; just don't use them. But certainly don't blame the tools for
your mistake.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to