From 176d6f5b74f5f61908d92ec2d780070676b557e9 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 23 Oct 2017 00:52:33 -0700 Subject: [PATCH] Simplify declaration of install_requires. The previous way of declaring install_requires is way too overengineered now that we unconditionally rely on the standard dependency resolution machinery. Don't use environment markers on install_requires as who knows what version of setuptools & pip does the end user have. Drop the check on Tornado as we don't do anything with it. --- setup.py | 18 +----- setupext.py | 175 +++++----------------------------------------------- 2 files changed, 17 insertions(+), 176 deletions(-) diff --git a/setup.py b/setup.py index 9a60d269cf2c..189c1bc2f576 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ from __future__ import print_function, absolute_import from string import Template +from setuptools import setup from setuptools.command.test import test as TestCommand from setuptools.command.build_ext import build_ext as BuildExtCommand @@ -27,14 +28,6 @@ if os.path.exists('MANIFEST'): os.remove('MANIFEST') -try: - from setuptools import setup -except ImportError: - try: - from setuptools.core import setup - except ImportError: - from distutils.core import setup - # The setuptools version of sdist adds a setup.cfg file to the tree. # We don't want that, so we simply remove it, and it will fall back to # vanilla distutils. @@ -64,14 +57,7 @@ setupext.Platform(), 'Required dependencies and extensions', setupext.Numpy(), - setupext.Six(), - setupext.Dateutil(), - setupext.BackportsFuncToolsLRUCache(), - setupext.Subprocess32(), - setupext.Pytz(), - setupext.Cycler(), - setupext.Tornado(), - setupext.Pyparsing(), + setupext.InstallRequires(), setupext.LibAgg(), setupext.FreeType(), setupext.FT2Font(), diff --git a/setupext.py b/setupext.py index c56ee47cd30e..ad3cd3337753 100644 --- a/setupext.py +++ b/setupext.py @@ -1450,170 +1450,25 @@ def get_extension(self): return ext -class Six(SetupPackage): - name = "six" - min_version = "1.10" +class InstallRequires(SetupPackage): + name = "install_requires" def check(self): - try: - import six - except ImportError: - return ( - "six was not found." - "pip will attempt to install it " - "after matplotlib.") - - if not is_min_version(six.__version__, self.min_version): - return ("The installed version of six is {inst_ver} but " - "a the minimum required version is {min_ver}. " - "pip/easy install will attempt to install a " - "newer version." - ).format(min_ver=self.min_version, - inst_ver=six.__version__) - - return "using six version %s" % six.__version__ - - def get_install_requires(self): - return ['six>={0}'.format(self.min_version)] - - -class Pytz(SetupPackage): - name = "pytz" - - def check(self): - try: - import pytz - except ImportError: - return ( - "pytz was not found. " - "pip/easy_install may attempt to install it " - "after matplotlib.") - - return "using pytz version %s" % pytz.__version__ - - def get_install_requires(self): - return ['pytz'] - - -class Cycler(SetupPackage): - name = "cycler" - - def check(self): - try: - import cycler - except ImportError: - return ( - "cycler was not found. " - "pip/easy_install may attempt to install it " - "after matplotlib.") - return "using cycler version %s" % cycler.__version__ - - def get_install_requires(self): - return ['cycler>=0.10'] - - -class Dateutil(SetupPackage): - name = "dateutil" - - def __init__(self, version='>=2.0'): - self.version = version - - def check(self): - try: - import dateutil - except ImportError: - return ( - "dateutil was not found. It is required for date axis " - "support. pip/easy_install may attempt to install it " - "after matplotlib.") - - return "using dateutil version %s" % dateutil.__version__ - - def get_install_requires(self): - dateutil = 'python-dateutil' - if self.version is not None: - dateutil += self.version - return [dateutil] - - -class BackportsFuncToolsLRUCache(SetupPackage): - name = "backports.functools_lru_cache" - - def check(self): - if not PY3min: - try: - import backports.functools_lru_cache - except ImportError: - return ( - "backports.functools_lru_cache was not found. It is required for" - "Python versions prior to 3.2") - - return "using backports.functools_lru_cache" - else: - return "Not required" - - def get_install_requires(self): - if not PY3min: - return ['backports.functools_lru_cache'] - else: - return [] - - -class Subprocess32(SetupPackage): - name = "subprocess32" - - def check(self): - if not PY3min: - try: - import subprocess32 - except ImportError: - return ( - "subprocess32 was not found. It used " - " for Python versions prior to 3.2 to improves" - " functionality on Linux and OSX") - - return "using subprocess32" - else: - return "Not required" - - def get_install_requires(self): - if not PY3min and os.name == 'posix': - return ['subprocess32'] - else: - return [] - - -class Tornado(OptionalPackage): - name = "tornado" - - def check(self): - try: - import tornado - except ImportError: - return ( - "tornado was not found. It is required for the WebAgg " - "backend. pip/easy_install may attempt to install it " - "after matplotlib.") - - return "using tornado version %s" % tornado.version - - -class Pyparsing(SetupPackage): - name = "pyparsing" - - def check(self): - try: - import pyparsing - except ImportError: - return ( - "pyparsing was not found. It is required for mathtext " - "support. pip/easy_install may attempt to install it " - "after matplotlib.") - - return "using pyparsing version %s" % pyparsing.__version__ + return "handled by setuptools" def get_install_requires(self): - return ['pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6'] + install_requires = [ + "cycler>=0.10", + "pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6", + "python-dateutil>=2.0", + "pytz", + "six>=1.10", + ] + if sys.version_info < (3,): + install_requires += ["backports.functools_lru_cache"] + if sys.version_info < (3,) and os.name == "posix": + install_requires += ["subprocess32"] + return install_requires class BackendAgg(OptionalBackendPackage):