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

Skip to content

Commit e344d21

Browse files
authored
Merge pull request #9536 from anntzer/setuptools-install_requires
Simplify declaration of install_requires.
2 parents d603165 + 176d6f5 commit e344d21

File tree

2 files changed

+17
-176
lines changed

2 files changed

+17
-176
lines changed

setup.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import print_function, absolute_import
77
from string import Template
8+
from setuptools import setup
89
from setuptools.command.test import test as TestCommand
910
from setuptools.command.build_ext import build_ext as BuildExtCommand
1011

@@ -27,14 +28,6 @@
2728
if os.path.exists('MANIFEST'):
2829
os.remove('MANIFEST')
2930

30-
try:
31-
from setuptools import setup
32-
except ImportError:
33-
try:
34-
from setuptools.core import setup
35-
except ImportError:
36-
from distutils.core import setup
37-
3831
# The setuptools version of sdist adds a setup.cfg file to the tree.
3932
# We don't want that, so we simply remove it, and it will fall back to
4033
# vanilla distutils.
@@ -64,14 +57,7 @@
6457
setupext.Platform(),
6558
'Required dependencies and extensions',
6659
setupext.Numpy(),
67-
setupext.Six(),
68-
setupext.Dateutil(),
69-
setupext.BackportsFuncToolsLRUCache(),
70-
setupext.Subprocess32(),
71-
setupext.Pytz(),
72-
setupext.Cycler(),
73-
setupext.Tornado(),
74-
setupext.Pyparsing(),
60+
setupext.InstallRequires(),
7561
setupext.LibAgg(),
7662
setupext.FreeType(),
7763
setupext.FT2Font(),

setupext.py

Lines changed: 15 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,170 +1450,25 @@ def get_extension(self):
14501450
return ext
14511451

14521452

1453-
class Six(SetupPackage):
1454-
name = "six"
1455-
min_version = "1.10"
1453+
class InstallRequires(SetupPackage):
1454+
name = "install_requires"
14561455

14571456
def check(self):
1458-
try:
1459-
import six
1460-
except ImportError:
1461-
return (
1462-
"six was not found."
1463-
"pip will attempt to install it "
1464-
"after matplotlib.")
1465-
1466-
if not is_min_version(six.__version__, self.min_version):
1467-
return ("The installed version of six is {inst_ver} but "
1468-
"a the minimum required version is {min_ver}. "
1469-
"pip/easy install will attempt to install a "
1470-
"newer version."
1471-
).format(min_ver=self.min_version,
1472-
inst_ver=six.__version__)
1473-
1474-
return "using six version %s" % six.__version__
1475-
1476-
def get_install_requires(self):
1477-
return ['six>={0}'.format(self.min_version)]
1478-
1479-
1480-
class Pytz(SetupPackage):
1481-
name = "pytz"
1482-
1483-
def check(self):
1484-
try:
1485-
import pytz
1486-
except ImportError:
1487-
return (
1488-
"pytz was not found. "
1489-
"pip/easy_install may attempt to install it "
1490-
"after matplotlib.")
1491-
1492-
return "using pytz version %s" % pytz.__version__
1493-
1494-
def get_install_requires(self):
1495-
return ['pytz']
1496-
1497-
1498-
class Cycler(SetupPackage):
1499-
name = "cycler"
1500-
1501-
def check(self):
1502-
try:
1503-
import cycler
1504-
except ImportError:
1505-
return (
1506-
"cycler was not found. "
1507-
"pip/easy_install may attempt to install it "
1508-
"after matplotlib.")
1509-
return "using cycler version %s" % cycler.__version__
1510-
1511-
def get_install_requires(self):
1512-
return ['cycler>=0.10']
1513-
1514-
1515-
class Dateutil(SetupPackage):
1516-
name = "dateutil"
1517-
1518-
def __init__(self, version='>=2.0'):
1519-
self.version = version
1520-
1521-
def check(self):
1522-
try:
1523-
import dateutil
1524-
except ImportError:
1525-
return (
1526-
"dateutil was not found. It is required for date axis "
1527-
"support. pip/easy_install may attempt to install it "
1528-
"after matplotlib.")
1529-
1530-
return "using dateutil version %s" % dateutil.__version__
1531-
1532-
def get_install_requires(self):
1533-
dateutil = 'python-dateutil'
1534-
if self.version is not None:
1535-
dateutil += self.version
1536-
return [dateutil]
1537-
1538-
1539-
class BackportsFuncToolsLRUCache(SetupPackage):
1540-
name = "backports.functools_lru_cache"
1541-
1542-
def check(self):
1543-
if not PY3min:
1544-
try:
1545-
import backports.functools_lru_cache
1546-
except ImportError:
1547-
return (
1548-
"backports.functools_lru_cache was not found. It is required for"
1549-
"Python versions prior to 3.2")
1550-
1551-
return "using backports.functools_lru_cache"
1552-
else:
1553-
return "Not required"
1554-
1555-
def get_install_requires(self):
1556-
if not PY3min:
1557-
return ['backports.functools_lru_cache']
1558-
else:
1559-
return []
1560-
1561-
1562-
class Subprocess32(SetupPackage):
1563-
name = "subprocess32"
1564-
1565-
def check(self):
1566-
if not PY3min:
1567-
try:
1568-
import subprocess32
1569-
except ImportError:
1570-
return (
1571-
"subprocess32 was not found. It used "
1572-
" for Python versions prior to 3.2 to improves"
1573-
" functionality on Linux and OSX")
1574-
1575-
return "using subprocess32"
1576-
else:
1577-
return "Not required"
1578-
1579-
def get_install_requires(self):
1580-
if not PY3min and os.name == 'posix':
1581-
return ['subprocess32']
1582-
else:
1583-
return []
1584-
1585-
1586-
class Tornado(OptionalPackage):
1587-
name = "tornado"
1588-
1589-
def check(self):
1590-
try:
1591-
import tornado
1592-
except ImportError:
1593-
return (
1594-
"tornado was not found. It is required for the WebAgg "
1595-
"backend. pip/easy_install may attempt to install it "
1596-
"after matplotlib.")
1597-
1598-
return "using tornado version %s" % tornado.version
1599-
1600-
1601-
class Pyparsing(SetupPackage):
1602-
name = "pyparsing"
1603-
1604-
def check(self):
1605-
try:
1606-
import pyparsing
1607-
except ImportError:
1608-
return (
1609-
"pyparsing was not found. It is required for mathtext "
1610-
"support. pip/easy_install may attempt to install it "
1611-
"after matplotlib.")
1612-
1613-
return "using pyparsing version %s" % pyparsing.__version__
1457+
return "handled by setuptools"
16141458

16151459
def get_install_requires(self):
1616-
return ['pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6']
1460+
install_requires = [
1461+
"cycler>=0.10",
1462+
"pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6",
1463+
"python-dateutil>=2.0",
1464+
"pytz",
1465+
"six>=1.10",
1466+
]
1467+
if sys.version_info < (3,):
1468+
install_requires += ["backports.functools_lru_cache"]
1469+
if sys.version_info < (3,) and os.name == "posix":
1470+
install_requires += ["subprocess32"]
1471+
return install_requires
16171472

16181473

16191474
class BackendAgg(OptionalBackendPackage):

0 commit comments

Comments
 (0)