From 7e2b2197f1cb394f54a65a2e9febf194e878f3f6 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 30 Aug 2018 02:56:38 +0200 Subject: [PATCH] Remove __version__numpy__; simplify dependencies check. - There isn't really a reason to keep a ton of machinery to propagate `__version__numpy__` as min numpy supported version throughout the repo; we don't do this with other dependencies so I'm sure we can manage manually bumping the numpy version at all places when we want to. - Kill Numpy().check() in setupext. Numpy will always be installed due to its presence in setup_requires -- unless you don't believe in setuptools... - Simplify the version check at import time. If the module isn't present, I think leaving in the ImportError that would have been generated is just fine (note that on recent Pythons it's actually a ModuleNotFoundError which contains *more* information, wrapping it in an ImportError ourselves actually decreases the amount of information available... --- INSTALL.rst | 2 +- ...5-15-AL.rst => 2018-05-15-AL-removals.rst} | 0 doc/api/next_api_changes/2018-08-31-AL.rst | 6 ++++ doc/conf.py | 4 --- lib/matplotlib/__init__.py | 34 +++++++------------ setupext.py | 26 -------------- 6 files changed, 20 insertions(+), 52 deletions(-) rename doc/api/next_api_changes/{2018-05-15-AL.rst => 2018-05-15-AL-removals.rst} (100%) create mode 100644 doc/api/next_api_changes/2018-08-31-AL.rst diff --git a/INSTALL.rst b/INSTALL.rst index 9e1b1338e608..6f780bb9bbdf 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -138,7 +138,7 @@ Matplotlib requires the following dependencies: * `Python `_ (>= 3.5) * `FreeType `_ (>= 2.3) * `libpng `_ (>= 1.2) -* `NumPy `_ (>= |minimum_numpy_version|) +* `NumPy `_ (>= 1.10.0) * `setuptools `_ * `cycler `_ (>= 0.10.0) * `dateutil `_ (>= 2.1) diff --git a/doc/api/next_api_changes/2018-05-15-AL.rst b/doc/api/next_api_changes/2018-05-15-AL-removals.rst similarity index 100% rename from doc/api/next_api_changes/2018-05-15-AL.rst rename to doc/api/next_api_changes/2018-05-15-AL-removals.rst diff --git a/doc/api/next_api_changes/2018-08-31-AL.rst b/doc/api/next_api_changes/2018-08-31-AL.rst new file mode 100644 index 000000000000..5510ffd4d87a --- /dev/null +++ b/doc/api/next_api_changes/2018-08-31-AL.rst @@ -0,0 +1,6 @@ +API removals +```````````` + +The following API elements have been removed: + +- ``__version__numpy__`` diff --git a/doc/conf.py b/doc/conf.py index 5b2395702e62..095ea340abd1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -314,10 +314,6 @@ def _check_deps(): # documentation autoclass_content = 'both' -rst_epilog = """ -.. |minimum_numpy_version| replace:: %s -""" % matplotlib.__version__numpy__ - texinfo_documents = [ ("contents", 'matplotlib', 'Matplotlib Documentation', 'John Hunter@*Darren Dale@*Eric Firing@*Michael Droettboom@*' diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 1e87a0a968d4..3ca8a1d1243f 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -153,8 +153,6 @@ _log = logging.getLogger(__name__) -__version__numpy__ = '1.10.0' # minimum required numpy version - __bibtex__ = r"""@Article{Hunter:2007, Author = {Hunter, J. D.}, Title = {Matplotlib: A 2D graphics environment}, @@ -189,27 +187,21 @@ def compare_versions(a, b): return False -try: - import dateutil -except ImportError: - raise ImportError("Matplotlib requires dateutil") - - -try: - import pyparsing -except ImportError: - raise ImportError("Matplotlib requires pyparsing") -else: - if not compare_versions(pyparsing.__version__, '2.0.1'): - raise ImportError( - "Matplotlib requires pyparsing>=2.0.1; you have %s" - % pyparsing.__version__) +def _check_versions(): + for modname, minver in [ + ("cycler", "0.10"), + ("dateutil", "2.1"), + ("kiwisolver", "1.0.1"), + ("numpy", "1.10"), + ("pyparsing", "2.0.1"), + ]: + module = importlib.import_module(modname) + if distutils.version.LooseVersion(module.__version__) < minver: + raise ImportError("Matplotlib requires {}>={}; you have {}" + .format(modname, minver, module.__version__)) -if not compare_versions(numpy.__version__, __version__numpy__): - raise ImportError( - "Matplotlib requires numpy>=%s; you have %s" % ( - __version__numpy__, numpy.__version__)) +_check_versions() if not hasattr(sys, 'argv'): # for modpython diff --git a/setupext.py b/setupext.py index 5a10d87ef111..9ff35cd9f095 100644 --- a/setupext.py +++ b/setupext.py @@ -89,18 +89,6 @@ def _get_xdg_cache_dir(): options['local_freetype'] = lft or options.get('local_freetype', False) -def extract_versions(): - """ - Extracts version values from the main matplotlib __init__.py and - returns them as a dictionary. - """ - with open('lib/matplotlib/__init__.py') as fd: - for line in fd.readlines(): - if line.startswith('__version__numpy__'): - exec(line.strip()) - return locals() - - def has_include_file(include_dirs, filename): """ Returns `True` if *filename* can be found in one of the @@ -855,20 +843,6 @@ def include_dirs_hook(): return [numpy.get_include()] - def check(self): - min_version = extract_versions()['__version__numpy__'] - try: - import numpy - except ImportError: - return 'not found. pip may install it below.' - - if not is_min_version(numpy.__version__, min_version): - raise SystemExit( - "Requires numpy %s or later to build. (Found %s)" % - (min_version, numpy.__version__)) - - return 'version %s' % numpy.__version__ - def add_flags(self, ext): # Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for # each extension