Skip to content

Commit ebd8315

Browse files
committed
Merge pull request #188 from markmuetz/pip_install
Allow basemap to be installed using pip, virtualenv and a requirements.txt file
2 parents ee6a2f7 + 8055017 commit ebd8315

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

setup.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
import sys, glob, os, numpy, subprocess
1+
import sys, glob, os, subprocess
2+
23
major, minor1, minor2, s, tmp = sys.version_info
34
if major==2 and minor1<4 or major<2:
45
raise SystemExit("""matplotlib and the basemap toolkit require Python 2.4 or later.""")
5-
from numpy.distutils.core import setup, Extension
6+
7+
from distutils.dist import Distribution
68
from distutils.util import convert_path
79
from distutils import ccompiler, sysconfig
10+
11+
# Do not require numpy for just querying the package
12+
# Taken from the netcdf-python setup file (which took it from h5py setup file).
13+
inc_dirs = []
14+
if any('--' + opt in sys.argv for opt in Distribution.display_option_names +
15+
['help-commands', 'help']) or sys.argv[1] == 'egg_info':
16+
from distutils.core import setup, Extension
17+
else:
18+
import numpy
19+
# Use numpy versions if they are available.
20+
from numpy.distutils.core import setup, Extension
21+
# append numpy include dir.
22+
inc_dirs.append(numpy.get_include())
23+
824
try:
925
from distutils.command.build_py import build_py_2to3 as build_py
1026
except ImportError:
@@ -62,7 +78,7 @@ def checkversion(GEOS_dir):
6278
manually and set the variable GEOS_dir (right after the line
6379
that says "set GEOS_dir manually here".""" % "', '".join(geos_search_locations))
6480
else:
65-
geos_include_dirs=[os.path.join(GEOS_dir,'include'),numpy.get_include()]
81+
geos_include_dirs=[os.path.join(GEOS_dir,'include'),inc_dirs]
6682
geos_library_dirs=[os.path.join(GEOS_dir,'lib'),os.path.join(GEOS_dir,'lib64')]
6783

6884
# proj4 and geos extensions.
@@ -130,6 +146,7 @@ def checkversion(GEOS_dir):
130146
download_url = "https://downloads.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-{0}/basemap-{0}.tar.gz".format(__version__),
131147
author = "Jeff Whitaker",
132148
author_email = "[email protected]",
149+
install_requires = ["numpy>=1.2.1", "matplotlib>=1.0.0"],
133150
platforms = ["any"],
134151
license = "OSI Approved",
135152
keywords = ["python","plotting","plots","graphs","charts","GIS","mapping","map projections","maps"],

0 commit comments

Comments
 (0)