Skip to content

Commit 28c89a5

Browse files
authored
Merge pull request #330 from nsoranzo/master
Wheel-compatible conditional requirements
2 parents 6005458 + 7c444e8 commit 28c89a5

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

setup.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Setuptools setup file, used to install or test 'cmd2'
55
"""
66
import sys
7+
8+
import setuptools
79
from setuptools import setup
810

911
VERSION = '0.8.2'
@@ -64,17 +66,23 @@
6466

6567
INSTALL_REQUIRES = ['pyparsing >= 2.0.1', 'pyperclip', 'six']
6668

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+
}
7477

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')
7886

7987
# unittest.mock was added in Python 3.3. mock is a backport of unittest.mock to all versions of Python
8088
TESTS_REQUIRE = ['mock', 'pytest', 'pytest-xdist']
@@ -94,5 +102,6 @@
94102
py_modules=["cmd2"],
95103
keywords='command prompt console cmd',
96104
install_requires=INSTALL_REQUIRES,
105+
extras_require=EXTRAS_REQUIRE,
97106
tests_require=TESTS_REQUIRE,
98107
)

0 commit comments

Comments
 (0)