Skip to content

Commit b256cd2

Browse files
committed
Add support for new environment marker usages
1 parent 794fb19 commit b256cd2

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ Tom Dalton
179179
Tom Viner
180180
Trevor Bekolay
181181
Tyler Goodlet
182+
Tzu-ping Chung
182183
Vasily Kuznetsov
183184
Victor Uriarte
184185
Vidar T. Fauske

setup.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,34 @@
2323
long_description = fd.read()
2424

2525

26-
def has_environment_marker_support():
26+
def get_environment_marker_support_level():
2727
"""
28-
Tests that setuptools has support for PEP-426 environment marker support.
28+
Tests how well setuptools supports PEP-426 environment marker.
2929
3030
The first known release to support it is 0.7 (and the earliest on PyPI seems to be 0.7.2
31-
so we're using that), see: http://pythonhosted.org/setuptools/history.html#id142
31+
so we're using that), see: https://setuptools.readthedocs.io/en/latest/history.html#id350
32+
33+
The support is later enhanced to allow direct conditional inclusions inside install_requires,
34+
which is now recommended by setuptools. It first appeared in 36.2.0, went broken with 36.2.1, and
35+
again worked since 36.2.2, so we're using that. See:
36+
https://setuptools.readthedocs.io/en/latest/history.html#v36-2-2
37+
https://github.com/pypa/setuptools/issues/1099
3238
3339
References:
3440
3541
* https://wheel.readthedocs.io/en/latest/index.html#defining-conditional-dependencies
3642
* https://www.python.org/dev/peps/pep-0426/#environment-markers
43+
* https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
3744
"""
3845
try:
39-
return pkg_resources.parse_version(setuptools.__version__) >= pkg_resources.parse_version('0.7.2')
46+
version = pkg_resources.parse_version(setuptools.__version__)
47+
if version >= pkg_resources.parse_version('36.2.2'):
48+
return 2
49+
if version >= pkg_resources.parse_version('0.7.2'):
50+
return 1
4051
except Exception as exc:
4152
sys.stderr.write("Could not test setuptool's version: %s\n" % exc)
42-
return False
53+
return 0
4354

4455

4556
def main():
@@ -54,7 +65,11 @@ def main():
5465
# used by tox.ini to test with pluggy master
5566
if '_PYTEST_SETUP_SKIP_PLUGGY_DEP' not in os.environ:
5667
install_requires.append('pluggy>=0.5,<0.7')
57-
if has_environment_marker_support():
68+
environment_marker_support_level = get_environment_marker_support_level()
69+
if environment_marker_support_level >= 2:
70+
install_requires.append('funcsigs;python_version<"3.0"')
71+
install_requires.append('colorama;sys_platform=="win32"')
72+
elif environment_marker_support_level == 1:
5873
extras_require[':python_version<"3.0"'] = ['funcsigs']
5974
extras_require[':sys_platform=="win32"'] = ['colorama']
6075
else:

0 commit comments

Comments
 (0)