23
23
long_description = fd .read ()
24
24
25
25
26
- def has_environment_marker_support ():
26
+ def get_environment_marker_support_level ():
27
27
"""
28
- Tests that setuptools has support for PEP-426 environment marker support .
28
+ Tests how well setuptools supports PEP-426 environment marker.
29
29
30
30
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
32
38
33
39
References:
34
40
35
41
* https://wheel.readthedocs.io/en/latest/index.html#defining-conditional-dependencies
36
42
* https://www.python.org/dev/peps/pep-0426/#environment-markers
43
+ * https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
37
44
"""
38
45
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
40
51
except Exception as exc :
41
52
sys .stderr .write ("Could not test setuptool's version: %s\n " % exc )
42
- return False
53
+ return 0
43
54
44
55
45
56
def main ():
@@ -54,7 +65,11 @@ def main():
54
65
# used by tox.ini to test with pluggy master
55
66
if '_PYTEST_SETUP_SKIP_PLUGGY_DEP' not in os .environ :
56
67
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 :
58
73
extras_require [':python_version<"3.0"' ] = ['funcsigs' ]
59
74
extras_require [':sys_platform=="win32"' ] = ['colorama' ]
60
75
else :
0 commit comments