From eb8efce7d8172e41139acd26196dd164c6272583 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 3 Oct 2017 09:46:28 +0100 Subject: [PATCH] requirements: Reduce duplication Simply installing packages will ensure that most of the dependencies in 'setup.py' are installed, meaning 'test-reqs.txt' need only contain those necessary for testing. The only notable change is that the 'simplejson' module is dropped from the requirements list. This included as a dependency for the PyPy target, but it appears that this is not necessary today (though it may have been when the target was added in 2011). This retains 'setup.py test' which, as noted in the tox docs [1], is sometimes expected for downstream distribution testing. We may wish to find a way to synchronize requirements between 'test-reqs.txt' and this section in the future, but that's work for another day. [1] https://tox.readthedocs.io/en/latest/example/basic.html#integration-with-setup-py-test-command Signed-off-by: Stephen Finucane --- .appveyor.yml | 4 ++-- .travis.yml | 3 ++- setup.py | 16 ++++++++++------ test-reqs.txt | 19 +++---------------- tox.ini | 21 +++------------------ 5 files changed, 20 insertions(+), 43 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index deaf503b7..a3f83394f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -18,8 +18,8 @@ environment: install: - C:\Python%PYTHON%\python.exe -m pip install -U pip setuptools - - C:\Python%PYTHON%\python.exe -m pip install docutils==%DOCUTILS% - - C:\Python%PYTHON%\python.exe -m pip install -r test-reqs.txt + - C:\Python%PYTHON%\python.exe -m pip install docutils==%DOCUTILS% mock + - C:\Python%PYTHON%\python.exe -m pip install .[test,websupport] # No automatic build, just run python tests build: off diff --git a/.travis.yml b/.travis.yml index 6df4f7cfb..73fd9c459 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,8 @@ addons: install: - pip install -U pip setuptools - pip install docutils==$DOCUTILS - - pip install -r test-reqs.txt + - pip install .[test,websupport] + - pip install flake8 - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then python3.6 -m pip install mypy typed-ast; fi script: - flake8 diff --git a/setup.py b/setup.py index b2d7ad4cc..618620b50 100644 --- a/setup.py +++ b/setup.py @@ -69,10 +69,17 @@ extras_require = { ], 'test': [ 'pytest', - 'mock', # it would be better for 'test:python_version in 2.7' - 'simplejson', # better: 'test:platform_python_implementation=="PyPy"' + 'pytest-cov', 'html5lib', ], + 'test:python_version<"3"': [ + 'enum34', + 'mock', + ], + 'test:python_version>="3"': [ + 'mypy', + 'typed_ast', + ], } # Provide a "compile_catalog" command that also creates the translated @@ -83,10 +90,7 @@ cmdclass = {} try: from babel.messages.pofile import read_po from babel.messages.frontend import compile_catalog - try: - from simplejson import dump - except ImportError: - from json import dump + from json import dump except ImportError: pass else: diff --git a/test-reqs.txt b/test-reqs.txt index 3a7bde8ea..be15ff1ab 100644 --- a/test-reqs.txt +++ b/test-reqs.txt @@ -1,20 +1,7 @@ flake8 pytest>=3.0 pytest-cov -mock -six>=1.4 -Jinja2>=2.3 -Pygments>=2.0 -docutils>=0.11 -snowballstemmer>=1.1 -babel -sqlalchemy>=0.9 -whoosh>=2.0 -alabaster -sphinx_rtd_theme -sphinxcontrib-websupport -imagesize -requests html5lib -enum34 -typing +mock;python_version<'3.3' +mypy;python_version>='3.2' +typed_ast;python_version>='3.2' diff --git a/tox.ini b/tox.ini index 519020f98..d78754dd4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,10 @@ [tox] -envlist=flake8,py27,py34,py35,py36,pypy,du14,du13,du12,du11 +minversion=2.0 +envlist=flake8,mypy,py{27,34,35,36},pypy,du{11,12,13,14} [testenv] passenv = https_proxy http_proxy no_proxy -deps= - six - pytest - pytest-cov - html5lib - mock - enum34 - typing +deps=-rtest-reqs.txt setenv = SPHINX_TEST_TEMPDIR = {envdir}/testbuild commands= @@ -18,11 +12,6 @@ commands= --durations 25 {posargs} sphinx-build -q -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html -[testenv:pypy] -deps= - simplejson - {[testenv]deps} - [testenv:du11] deps= docutils==0.11 @@ -59,10 +48,6 @@ deps= {[testenv]deps} [testenv:py35] -deps= - mypy - typed_ast - {[testenv]deps} commands= {envpython} -Wall tests/run.py --cov=sphinx --durations 25 {posargs} sphinx-build -q -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html