Skip to content

Commit 1b88187

Browse files
committed
Make basemap work with mpl 1.4 egg directory as generated by setuptools
Starting in version 1.4, mpl is installing mpl_toolkits inside its egg. To work with that, basemap needs to declare mpl_toolkits as a namespace package, and put a suitable __init__.py in it.
1 parent 5625c31 commit 1b88187

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/mpl_toolkits/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
try:
2+
__import__('pkg_resources').declare_namespace(__name__)
3+
except ImportError:
4+
pass # must not have setuptools
5+

setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ def checkversion(GEOS_dir):
6464
deps.remove(os.path.join('src','_geoslib.c'))
6565

6666
packages = ['mpl_toolkits','mpl_toolkits.basemap']
67+
namespace_packages = ['mpl_toolkits']
6768
package_dirs = {'':'lib'}
6869
extensions = [Extension("mpl_toolkits.basemap._proj",deps+['src/_proj.c'],include_dirs = ['src'],)]
6970
# can't install _geoslib in mpl_toolkits.basemap namespace,
7071
# or Basemap objects won't be pickleable.
71-
if sys.platform == 'win32':
72+
if sys.platform == 'win32':
7273
# don't use runtime_library_dirs on windows (workaround
7374
# for a distutils bug - http://bugs.python.org/issue2437).
7475
#extensions.append(Extension("mpl_toolkits.basemap._geoslib",['src/_geoslib.c'],
@@ -91,7 +92,7 @@ def checkversion(GEOS_dir):
9192
if sys.argv[1] not in ['sdist','clean']:
9293
cc = ccompiler.new_compiler()
9394
sysconfig.get_config_vars()
94-
sysconfig.customize_compiler(cc)
95+
sysconfig.customize_compiler(cc)
9596
cc.set_include_dirs(['src'])
9697
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
9798
execname = 'nad2bin'
@@ -125,14 +126,15 @@ def checkversion(GEOS_dir):
125126
license = "OSI Approved",
126127
keywords = ["python","plotting","plots","graphs","charts","GIS","mapping","map projections","maps"],
127128
classifiers = ["Development Status :: 5 - Production/Stable",
128-
"Intended Audience :: Science/Research",
129-
"License :: OSI Approved",
129+
"Intended Audience :: Science/Research",
130+
"License :: OSI Approved",
130131
"Programming Language :: Python",
131132
"Programming Language :: Python :: 3",
132133
"Topic :: Scientific/Engineering :: Visualization",
133134
"Topic :: Software Development :: Libraries :: Python Modules",
134135
"Operating System :: OS Independent"],
135136
packages = packages,
137+
namespace_packages = namespace_packages,
136138
package_dir = package_dirs,
137139
ext_modules = extensions,
138140
cmdclass = {'build_py': build_py},

0 commit comments

Comments
 (0)