Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 488563f

Browse files
authored
Merge pull request #11980 from anntzer/versioncheck
Remove __version__numpy__; simplify dependencies check.
2 parents 22dffea + 7e2b219 commit 488563f

File tree

6 files changed

+20
-52
lines changed

6 files changed

+20
-52
lines changed

INSTALL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Matplotlib requires the following dependencies:
138138
* `Python <https://www.python.org/downloads/>`_ (>= 3.5)
139139
* `FreeType <https://www.freetype.org/>`_ (>= 2.3)
140140
* `libpng <http://www.libpng.org>`_ (>= 1.2)
141-
* `NumPy <http://www.numpy.org>`_ (>= |minimum_numpy_version|)
141+
* `NumPy <http://www.numpy.org>`_ (>= 1.10.0)
142142
* `setuptools <https://setuptools.readthedocs.io/en/latest/>`_
143143
* `cycler <http://matplotlib.org/cycler/>`_ (>= 0.10.0)
144144
* `dateutil <https://pypi.python.org/pypi/python-dateutil>`_ (>= 2.1)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
API removals
2+
````````````
3+
4+
The following API elements have been removed:
5+
6+
- ``__version__numpy__``

doc/conf.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,6 @@ def _check_deps():
314314
# documentation
315315
autoclass_content = 'both'
316316

317-
rst_epilog = """
318-
.. |minimum_numpy_version| replace:: %s
319-
""" % matplotlib.__version__numpy__
320-
321317
texinfo_documents = [
322318
("contents", 'matplotlib', 'Matplotlib Documentation',
323319
'John Hunter@*Darren Dale@*Eric Firing@*Michael Droettboom@*'

lib/matplotlib/__init__.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@
153153

154154
_log = logging.getLogger(__name__)
155155

156-
__version__numpy__ = '1.10.0' # minimum required numpy version
157-
158156
__bibtex__ = r"""@Article{Hunter:2007,
159157
Author = {Hunter, J. D.},
160158
Title = {Matplotlib: A 2D graphics environment},
@@ -189,27 +187,21 @@ def compare_versions(a, b):
189187
return False
190188

191189

192-
try:
193-
import dateutil
194-
except ImportError:
195-
raise ImportError("Matplotlib requires dateutil")
196-
197-
198-
try:
199-
import pyparsing
200-
except ImportError:
201-
raise ImportError("Matplotlib requires pyparsing")
202-
else:
203-
if not compare_versions(pyparsing.__version__, '2.0.1'):
204-
raise ImportError(
205-
"Matplotlib requires pyparsing>=2.0.1; you have %s"
206-
% pyparsing.__version__)
190+
def _check_versions():
191+
for modname, minver in [
192+
("cycler", "0.10"),
193+
("dateutil", "2.1"),
194+
("kiwisolver", "1.0.1"),
195+
("numpy", "1.10"),
196+
("pyparsing", "2.0.1"),
197+
]:
198+
module = importlib.import_module(modname)
199+
if distutils.version.LooseVersion(module.__version__) < minver:
200+
raise ImportError("Matplotlib requires {}>={}; you have {}"
201+
.format(modname, minver, module.__version__))
207202

208203

209-
if not compare_versions(numpy.__version__, __version__numpy__):
210-
raise ImportError(
211-
"Matplotlib requires numpy>=%s; you have %s" % (
212-
__version__numpy__, numpy.__version__))
204+
_check_versions()
213205

214206

215207
if not hasattr(sys, 'argv'): # for modpython

setupext.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,6 @@ def _get_xdg_cache_dir():
8989
options['local_freetype'] = lft or options.get('local_freetype', False)
9090

9191

92-
def extract_versions():
93-
"""
94-
Extracts version values from the main matplotlib __init__.py and
95-
returns them as a dictionary.
96-
"""
97-
with open('lib/matplotlib/__init__.py') as fd:
98-
for line in fd.readlines():
99-
if line.startswith('__version__numpy__'):
100-
exec(line.strip())
101-
return locals()
102-
103-
10492
def has_include_file(include_dirs, filename):
10593
"""
10694
Returns `True` if *filename* can be found in one of the
@@ -855,20 +843,6 @@ def include_dirs_hook():
855843

856844
return [numpy.get_include()]
857845

858-
def check(self):
859-
min_version = extract_versions()['__version__numpy__']
860-
try:
861-
import numpy
862-
except ImportError:
863-
return 'not found. pip may install it below.'
864-
865-
if not is_min_version(numpy.__version__, min_version):
866-
raise SystemExit(
867-
"Requires numpy %s or later to build. (Found %s)" %
868-
(min_version, numpy.__version__))
869-
870-
return 'version %s' % numpy.__version__
871-
872846
def add_flags(self, ext):
873847
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for
874848
# each extension

0 commit comments

Comments
 (0)