Skip to content

Commit

Permalink
setup.py: require pytest-runner only when necessary (#119)
Browse files Browse the repository at this point in the history
This optimizes setup.py for cases when pytest-runner is not needed,
using the approach that is suggested upstream:

https://pypi.python.org/pypi/pytest-runner#conditional-requirement
  • Loading branch information
zmedico authored and dan-blanchard committed Apr 21, 2017
1 parent bb2672e commit b874c25
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/usr/bin/env python
import re
import sys

from setuptools import find_packages, setup


needs_pytest = set(['pytest', 'test', 'ptr']).intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []


# Get version without importing, which avoids dependency issues
def get_version():
with open('chardet/version.py') as version_file:
Expand Down Expand Up @@ -46,7 +51,7 @@ def readme():
"Modules"),
"Topic :: Text Processing :: Linguistic"],
packages=find_packages(),
setup_requires=['pytest-runner'],
setup_requires=pytest_runner,
tests_require=['pytest', 'hypothesis'],
entry_points={'console_scripts':
['chardetect = chardet.cli.chardetect:main']})

0 comments on commit b874c25

Please sign in to comment.