namespace packages (was: Basemap installation question)

Fought, Richard wrote:

Hi Jeff,

Thanks for your response. I might be able to upgrade my prototype machine to Python 2.4, but I'm not sure about my customer's box.

Here is the listing from

python2.3/site-packages/matplotlib-0.91.1_r0-py2.3-linux-i686.egg/matp
    

lo
tlib/toolkits:

__init__.py
__init__.pyc

Regards,
Rich Fought
  

Rich: That's it? I expected to see a basemap directory installed there. Can you send me a listing of the basemap directory in site-packages?

-Jeff

Directory listing of
python2.3/site-packages/basemap-0.9.9-py2.3-linux-i686.egg :

drwxr-xr-x 4 root root 4096 Jan 4 17:33 dap
drwxr-xr-x 2 root root 4096 Jan 4 17:33 dbflib
-rwxr-xr-x 1 root root 258 Jan 4 17:33 dbflibc.py
-rwxr-xr-x 1 root root 614 Jan 4 17:33 dbflibc.pyc
-rwxr-xr-x 1 root root 74526 Jan 4 17:33 dbflibc.so
drwxr-xr-x 2 root root 4096 Jan 4 17:33 EGG-INFO
-rwxr-xr-x 1 root root 256 Jan 4 17:33 _geos.py
-rwxr-xr-x 1 root root 608 Jan 4 17:33 _geos.pyc
-rwxr-xr-x 1 root root 88557 Jan 4 17:33 _geos.so
drwxr-xr-x 2 root root 4096 Jan 4 17:33 httplib2
drwxr-xr-x 3 root root 4096 Jan 4 17:33 matplotlib
drwxr-xr-x 2 root root 4096 Jan 4 17:33 shapelib
-rwxr-xr-x 1 root root 260 Jan 4 17:33 shapelibc.py
-rwxr-xr-x 1 root root 620 Jan 4 17:33 shapelibc.pyc
-rwxr-xr-x 1 root root 92671 Jan 4 17:33 shapelibc.so
-rwxr-xr-x 1 root root 258 Jan 4 17:33 shptree.py
-rwxr-xr-x 1 root root 614 Jan 4 17:33 shptree.pyc
-rwxr-xr-x 1 root root 19958 Jan 4 17:33 shptree.so

As you can see, there is a matplotlib folder here with the following
structure:

matplotlib
>_toolkits
    >_basemap

I created a symbolic link to this basemap directory in the
matplotlib/toolkits directory and simpletest.py works now, though I
still get the warning message

/usr/lib/python2.3/site-packages/matplotlib-0.91.1_r0-py2.3-linux-i686.e
gg/pytz/ __init__.py:29: UserWarning: Module matplotlib was already
imported from /usr/li
b/python2.3/site-packages/matplotlib-0.91.1_r0-py2.3-linux-i686.egg/matp
lotlib/_ _init__.pyc, but
/usr/lib/python2.3/site-packages/basemap-0.9.9-py2.3-linux-i686 .egg is
being added to sys.path
  from pkg_resources import resource_stream

I guess the basemap installer just installed the toolkit in the wrong
place.

Regards,
Rich
  
Rich: I think this is happening because matplotlib (and the basemap toolkit) needs to use namespace packages (http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages) in order for the basemap stuff to be picked up from the matplotlib.toolkits namespace when basemap is installed as an egg. If it's installed using distutils (instead of setuptools), the basemap stuff just gets written in the matplotlib toolkits directory directly, and everything works fine.

I think namespace packages were being used before, but were removed. I don't remember why.

Until we get this fixed, I think your symlink trick is the only way to get it to work with python2.3. The warning message appears to be harmless.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

We removed the namespace packages support because we were using it
improperly. To do it correctly would require moving all of the
functionality out of matplotlib/__init__.py. Since there is currently
a fair amount of functionality there, adding namespace support would
require moving it and breaking the current API. In addition, there are
some ongoing issues with performance and namespace packages. Because
of this, we had some ambivalence about namespace packages and decided
to remove the broken support until we could add proper support, if we
decide to go that route. A good time to do that, if indeed we want
to, would be when we release Michael's transforms branch, so we can
break as much as possible at once.

JDH

···

On Jan 7, 2008 2:15 PM, Jeff Whitaker <jswhit@...146...> wrote:

I think namespace packages were being used before, but were removed. I
don't remember why.

John Hunter wrote:

I think namespace packages were being used before, but were removed. I
don't remember why.
    
We removed the namespace packages support because we were using it
improperly. To do it correctly would require moving all of the
functionality out of matplotlib/__init__.py. Since there is currently
a fair amount of functionality there, adding namespace support would
require moving it and breaking the current API. In addition, there are
some ongoing issues with performance and namespace packages. Because
of this, we had some ambivalence about namespace packages and decided
to remove the broken support until we could add proper support, if we
decide to go that route. A good time to do that, if indeed we want
to, would be when we release Michael's transforms branch, so we can
break as much as possible at once.

JDH
  
John: OK, then I can think of two options for basemap in the interim:

1) remove setuptools support, since basemap cannot be installed as an egg without namespace packages. This means that python2.3 support would have to be dropped.

2) move the toolkits to basemap_toolkits, as Philip Eby suggested, and make matplotlib_toolkits a namespace package. Unfortunately, this may break lots of existing code.

-Jeff

···

On Jan 7, 2008 2:15 PM, Jeff Whitaker <jswhit@...146...> wrote:

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg