|
4 | 4 | Setuptools setup file, used to install or test 'cmd2' |
5 | 5 | """ |
6 | 6 | import sys |
| 7 | + |
| 8 | +import setuptools |
7 | 9 | from setuptools import setup |
8 | 10 |
|
9 | 11 | VERSION = '0.8.2' |
|
64 | 66 |
|
65 | 67 | INSTALL_REQUIRES = ['pyparsing >= 2.0.1', 'pyperclip', 'six'] |
66 | 68 |
|
67 | | -# Windows also requires pyreadline to ensure tab completion works |
68 | | -if sys.platform.startswith('win'): |
69 | | - INSTALL_REQUIRES += ['pyreadline'] |
70 | | - |
71 | | -# Python 3.4 and earlier require contextlib2 for temporarily redirecting stderr and stdout |
72 | | -if sys.version_info < (3, 5): |
73 | | - INSTALL_REQUIRES += ['contextlib2'] |
| 69 | +EXTRAS_REQUIRE = { |
| 70 | + # Windows also requires pyreadline to ensure tab completion works |
| 71 | + ":sys_platform=='win32'": ['pyreadline'], |
| 72 | + # Python 3.4 and earlier require contextlib2 for temporarily redirecting stderr and stdout |
| 73 | + ":python_version<'3.5'": ['contextlib2'], |
| 74 | + # Python 2.7 also requires subprocess32 |
| 75 | + ":python_version<'3.0'": ['subprocess32'], |
| 76 | +} |
74 | 77 |
|
75 | | -# Python 2.7 also requires subprocess32 |
76 | | -if sys.version_info < (3, 0): |
77 | | - INSTALL_REQUIRES += ['subprocess32'] |
| 78 | +if int(setuptools.__version__.split('.')[0]) < 18: |
| 79 | + EXTRAS_REQUIRE = {} |
| 80 | + if sys.platform.startswith('win'): |
| 81 | + INSTALL_REQUIRES.append('pyreadline') |
| 82 | + if sys.version_info < (3, 5): |
| 83 | + INSTALL_REQUIRES.append('contextlib2') |
| 84 | + if sys.version_info < (3, 0): |
| 85 | + INSTALL_REQUIRES.append('subprocess32') |
78 | 86 |
|
79 | 87 | # unittest.mock was added in Python 3.3. mock is a backport of unittest.mock to all versions of Python |
80 | 88 | TESTS_REQUIRE = ['mock', 'pytest', 'pytest-xdist'] |
|
94 | 102 | py_modules=["cmd2"], |
95 | 103 | keywords='command prompt console cmd', |
96 | 104 | install_requires=INSTALL_REQUIRES, |
| 105 | + extras_require=EXTRAS_REQUIRE, |
97 | 106 | tests_require=TESTS_REQUIRE, |
98 | 107 | ) |
0 commit comments