File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1111from os .path import isfile , join
1212import re
1313import logging
14+ import sys
1415from setuptools import setup , find_packages
1516
1617logging .basicConfig (level = logging .WARNING )
4142
4243extras_require ['test' ] = tests_require
4344
45+ # Check for 'pytest-runner' only if setup.py was invoked with 'test'.
46+ # This optimizes setup.py for cases when pytest-runner is not needed,
47+ # using the approach that is suggested upstream.
48+ #
49+ # See https://pypi.org/project/pytest-runner/#conditional-requirement
50+ needs_pytest = {"pytest" , "test" , "ptr" }.intersection (sys .argv )
51+ pytest_runner = ["pytest-runner" ] if needs_pytest else []
52+
4453
4554setup (
4655 # Description
104113 'typing;python_version<"3.5"' ,
105114 'windows-curses;platform_system=="Windows"' ,
106115 ],
107- setup_requires = [ "pytest-runner" ] ,
116+ setup_requires = pytest_runner ,
108117 extras_require = extras_require ,
109118 tests_require = tests_require
110119)
You can’t perform that action at this time.
0 commit comments