Skip to content

Commit 3c07ce4

Browse files
committed
Improve handling of requirements
1 parent 321d4a5 commit 3c07ce4

File tree

4 files changed

+132
-53
lines changed

4 files changed

+132
-53
lines changed

packages/basemap/requirements-dev.txt

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
flake8 >= 2.6, < 3.0; python_version == "2.6"
2+
flake8 >= 2.6, < 4.0; python_version == "2.7"
3+
flake8 >= 2.6, < 3.0; python_version == "3.2"
4+
flake8 >= 2.6, < 3.0; python_version == "3.3"
5+
flake8 >= 2.6, < 3.9; python_version == "3.4"
6+
flake8 >= 2.6, < 4.1; python_version >= "3.5"
7+
8+
astroid >= 1.6, < 2.0; python_version == "2.7"
9+
astroid >= 2.4, < 3.0; python_version >= "3.5"
10+
pylint >= 1.9, < 2.0; python_version == "2.7"
11+
pylint >= 2.6, < 3.0; python_version >= "3.5"
12+
113
unittest2
2-
netCDF4
3-
pillow
14+
15+
pytest >= 3.2, < 3.3; python_version == "2.6"
16+
pytest >= 3.2, < 5.0; python_version == "2.7"
17+
pytest >= 2.9, < 3.0; python_version == "3.2"
18+
pytest >= 3.2, < 3.3; python_version == "3.3"
19+
pytest >= 3.2, < 5.0; python_version == "3.4"
20+
pytest >= 3.2, < 6.3; python_version >= "3.5"
21+
22+
coverage >= 3.7, < 4.0; python_version == "3.2"
23+
24+
pytest-cov >= 2.5, < 2.6; python_version == "2.6"
25+
pytest-cov >= 2.5, < 3.0; python_version == "2.7"
26+
pytest-cov >= 2.5, < 2.6; python_version == "3.2"
27+
pytest-cov >= 2.5, < 2.6; python_version == "3.3"
28+
pytest-cov >= 2.5, < 2.9; python_version == "3.4"
29+
pytest-cov >= 2.5, < 3.1; python_version >= "3.5"
30+
31+
ordereddict; python_version == "2.6"
32+
netCDF4 >= 1.3, < 1.4; python_version < "3.6"
33+
netCDF4 >= 1.3, < 1.5.6; python_version >= "3.6"
34+
35+
pillow >= 3.4, < 4.0; python_version == "2.6"
36+
pillow >= 6.2, < 7.0; python_version == "2.7"
37+
pillow >= 3.4, < 4.0; python_version == "3.2"
38+
pillow >= 4.3, < 5.0; python_version == "3.3"
39+
pillow >= 5.4, < 6.0; python_version == "3.4"
40+
pillow >= 6.2, < 8.5; python_version >= "3.5"

packages/basemap/requirements-doc.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
six >= 1.10, < 1.16; python_version >= "3.5"
2+
sphinx >= 3.0, < 3.4; python_version >= "3.5"

packages/basemap/requirements.txt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
basemap_data
2-
matplotlib>=1.0.0,!=3.0.1
3-
numpy>=1.2.1
4-
pyproj>=1.9.3
5-
pyshp>=1.2.0
6-
six
2+
3+
six >= 1.10, < 1.16
4+
5+
numpy >= 1.11, < 1.12; python_version == "2.6"
6+
numpy >= 1.16, < 1.17; python_version == "2.7"
7+
numpy >= 1.11, < 1.12; python_version == "3.2"
8+
numpy >= 1.11, < 1.12; python_version == "3.3"
9+
numpy >= 1.11, < 1.17; python_version == "3.4"
10+
numpy >= 1.16, < 1.22; python_version >= "3.5"
11+
12+
cycler < 0.11; python_version == "3.2"
13+
pyparsing >= 1.5, < 2.4.1; python_version == "2.6"
14+
pyparsing >= 1.5, < 2.3.1; python_version == "3.2"
15+
matplotlib >= 1.5, < 2.0; python_version == "2.6"
16+
matplotlib >= 1.5, < 3.0; python_version == "2.7"
17+
matplotlib >= 1.5, < 2.0; python_version == "3.2"
18+
matplotlib >= 1.5, < 2.0; python_version == "3.3"
19+
matplotlib >= 1.5, < 3.0; python_version == "3.4"
20+
matplotlib >= 1.5, < 3.5; python_version >= "3.5"
21+
22+
pyproj >= 1.9.3, < 2.1.0; python_version == "2.6"
23+
pyproj >= 1.9.3, < 2.3.0; python_version == "2.7"
24+
pyproj >= 1.9.3, < 1.9.6; python_version == "3.2"
25+
pyproj >= 1.9.3, < 2.1.0; python_version == "3.3"
26+
pyproj >= 1.9.3, < 2.1.0; python_version == "3.4"
27+
pyproj >= 1.9.3, < 3.4.0; python_version >= "3.5"
28+
29+
pyshp >= 1.2, < 2.0; python_version == "2.6"
30+
pyshp >= 1.2, < 2.2; python_version >= "2.7"

packages/basemap/setup.py

Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io
77
import os
88
import sys
9+
import warnings
910
from setuptools import setup
1011
from setuptools import find_packages
1112
from setuptools.dist import Distribution
@@ -40,11 +41,24 @@ def checkversion(directory):
4041
return version
4142

4243

44+
# Initialise include and library dirs.
45+
include_dirs = []
46+
library_dirs = []
47+
48+
# Define NumPy include dirs.
49+
numpy_include_path = os.environ.get("NUMPY_INCLUDE_PATH", None)
50+
if numpy_include_path is not None:
51+
include_dirs.append(numpy_include_path)
52+
else:
53+
try:
54+
import numpy
55+
include_dirs.append(numpy.get_include())
56+
except ImportError as err:
57+
warnings.warn("unable to locate NumPy headers", RuntimeWarning)
58+
4359
# Define GEOS install directory (from environment variable or trying to guess).
4460
geos_installdir = os.environ.get("GEOS_DIR", None)
45-
if geos_installdir is not None:
46-
geos_version = checkversion(geos_installdir)
47-
else:
61+
if geos_installdir is None:
4862
# Define some default locations to find GEOS.
4963
geos_search_locations = [
5064
os.path.expanduser("~/local"),
@@ -57,56 +71,31 @@ def checkversion(directory):
5771
]
5872
# Loop over the default locations to see if we find something.
5973
for folder in geos_search_locations:
60-
# sys.stdout.write('checking for GEOS lib in %s ....\n' % folder)
6174
geos_version = checkversion(folder)
6275
if geos_version is not None and geos_version >= '"3.1.1"':
63-
# sys.stdout.write(
64-
# "GEOS lib (version %s) found in %s\n" %
65-
# (geos_version[1:-1], folder))
6676
geos_installdir = folder
6777
break
68-
if geos_installdir is None:
69-
raise OSError("\n".join([
70-
"Cannot find GEOS library in standard locations ('{0}').",
71-
"Please install the corresponding packages using your",
72-
"software management system or set the environment variable",
73-
"GEOS_DIR to point to the location where GEOS is installed",
74-
"(for example, if 'geos_c.h' is in '/usr/local/include'",
75-
"and 'libgeos_c' is in '/usr/local/lib', then you need to",
76-
"set GEOS_DIR to '/usr/local'",
77-
]).format("', '".join(geos_search_locations)))
78-
79-
# Define include dirs.
80-
include_dirs = [
81-
os.path.join(geos_installdir, "include")
82-
]
8378

84-
# Define include dirs for NumPy.
85-
# Do not import numpy for querying the package (taken from h5py setup).
86-
if not any("--" + opt in sys.argv
87-
for opt in Distribution.display_option_names +
88-
["help-commands", "help"]) or sys.argv[1] == "egg_info":
89-
# Try to read NumPy include path from environment variable.
90-
numpy_include_path = os.environ.get("NUMPY_INCLUDE_PATH", None)
91-
if numpy_include_path is None:
92-
try:
93-
import numpy
94-
numpy_include_path = numpy.get_include()
95-
except ImportError as err:
96-
err.args = ("unable to locate NumPy headers",)
97-
raise
98-
include_dirs.append(numpy_include_path)
99-
100-
# Define library dirs.
101-
library_dirs = [
102-
os.path.join(geos_installdir, "lib"),
103-
os.path.join(geos_installdir, "lib64"),
104-
]
79+
# Define GEOS include and library dirs.
80+
if geos_installdir is None:
81+
warnings.warn("\n".join([
82+
"Cannot find GEOS library in standard locations ('{0}').",
83+
"Please install the corresponding packages using your",
84+
"software management system or set the environment variable",
85+
"GEOS_DIR to point to the location where GEOS is installed",
86+
"(for example, if 'geos_c.h' is in '/usr/local/include'",
87+
"and 'libgeos_c' is in '/usr/local/lib', then you need to",
88+
"set GEOS_DIR to '/usr/local'",
89+
]).format("', '".join(geos_search_locations)), RuntimeWarning)
90+
else:
91+
include_dirs.append(os.path.join(geos_installdir, "include"))
92+
library_dirs.append(os.path.join(geos_installdir, "lib"))
93+
library_dirs.append(os.path.join(geos_installdir, "lib64"))
10594

10695
# Define runtime library dirs.
10796
# Don't use runtime_library_dirs on windows (workaround for a distutils bug):
10897
# http://bugs.python.org/issue2437)
109-
if sys.platform == "win32":
98+
if sys.platform != "win32":
11099
runtime_lib_dirs = []
111100
else:
112101
runtime_lib_dirs = library_dirs
@@ -132,6 +121,27 @@ def checkversion(directory):
132121
}),
133122
]
134123

124+
# Define all the different requirements.
125+
dev_requires = get_content("requirements-dev.txt", splitlines=True)
126+
doc_requires = get_content("requirements-doc.txt", splitlines=True)
127+
setup_requires = get_content("requirements-setup.txt", splitlines=True)
128+
install_requires = get_content("requirements.txt", splitlines=True)
129+
if sys.version_info[:2] == (3, 2):
130+
# Hack for Python 3.2 because pip < 8 cannot handle version markers.
131+
marker = '; python_version == "3.2"'
132+
dev_requires = [
133+
item.replace(marker, "") for item in dev_requires
134+
if item.endswith(marker) or "python_version" not in item]
135+
doc_requires = [
136+
item.replace(marker, "") for item in doc_requires
137+
if item.endswith(marker) or "python_version" not in item]
138+
setup_requires = [
139+
item.replace(marker, "") for item in setup_requires
140+
if item.endswith(marker) or "python_version" not in item]
141+
install_requires = [
142+
item.replace(marker, "") for item in install_requires
143+
if item.endswith(marker) or "python_version" not in item]
144+
135145
# To create the source .tar.gz file: python setup.py sdist
136146
# To create the universal wheel file: python setup.py bdist_wheel --universal
137147
setup(**{
@@ -190,9 +200,15 @@ def checkversion(directory):
190200
"<4",
191201
]),
192202
"setup_requires":
193-
get_content("requirements-setup.txt", splitlines=True),
203+
setup_requires,
194204
"install_requires":
195-
get_content("requirements.txt", splitlines=True),
205+
install_requires,
206+
"extras_require": {
207+
"dev":
208+
dev_requires,
209+
"doc":
210+
doc_requires,
211+
},
196212
"project_urls": {
197213
"Bug Tracker":
198214
"https://github.com/matplotlib/basemap/issues",

0 commit comments

Comments
 (0)