Skip to content

Commit 83c616d

Browse files
authored
Improve tox and add pyproject.toml (#1216)
* explain .gitignore * add documentations to tox.ini; python 3.7 to test envs * add coverage and timeout to tests * add pyproject.toml and isolated tox build
1 parent 29245ff commit 83c616d

File tree

4 files changed

+82
-33
lines changed

4 files changed

+82
-33
lines changed

.gitignore

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
# packaging
12
virtualenv.egg-info
23
build
34
dist
4-
docs/_build
5-
.DS_Store
6-
*.py[cod]
75
*.egg
86
.eggs
7+
8+
# documentation
9+
docs/_build
10+
11+
# python
12+
*.py[cod]
13+
14+
# tools
915
.tox
10-
.cache
16+
.*_cache
17+
.DS_Store
18+
19+
# tbd
1120
/tests/test_activate_output.actual
1221
/tests/test_activate_output.expected
22+
23+
# IDE
24+
.idea
25+
.vscode

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = [
3+
"setuptools >= 40.0.4",
4+
"wheel >= 0.29.0",
5+
]
6+
build-backend = 'setuptools.build_meta'

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import re
3-
import shutil
43
import sys
54

65
if sys.version_info[:2] < (2, 7):

tox.ini

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,67 @@
11
[tox]
2-
# env names must be a valid python binary name, unless they have a
3-
# separate configuration
4-
envlist =
5-
python{2.7,3.4,3.5,3.6}, pypy{,3}, crosspython{2,3}, docs
2+
minversion = 3.3.0
3+
envlist = py{27,34,35,36,37}, pypy{,3}, cross_python{2,3}, docs, package_readme
4+
isolated_build = true
5+
skip_missing_interpreters = true
66

77
[testenv]
8+
description = run tests with {basepython}
9+
setenv = PIP_DISABLE_VERSION_CHECK = 1
10+
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
11+
deps = mock
12+
pytest >= 3.0.0, <4
13+
pytest-cov >= 2.5.1, <3
14+
pytest-mock >= 1.10.0, <2
15+
pytest-timeout >= 1.3.0, <2
16+
commands = pytest {posargs:\
17+
--cov="virtualenv" \
18+
--cov-config="{toxinidir}/tox.ini" \
19+
--timeout=180 \
20+
--junitxml={env:JUNIT_XML_FILE:{toxworkdir}/.test.{envname}.xml} \
21+
. }
22+
23+
[coverage:run]
24+
branch = true
25+
26+
[coverage:report]
27+
skip_covered = True
28+
show_missing = True
29+
30+
[coverage:paths]
31+
source = virtualenv
32+
.tox/*/lib/python*/site-packages/virtualenv
33+
.tox/pypy*/site-packages/virtualenv
34+
.tox\*\Lib\site-packages\virtualenv
35+
*/virtualenv
36+
*\virtualenv
37+
38+
[testenv:cross_python2]
39+
description = test creating a python3 venv with a python2-based virtualenv
40+
basepython = python2
841
deps =
9-
mock
10-
pytest
11-
commands =
12-
py.test
13-
14-
# Creating a python3 venv with a python2-based virtualenv
15-
[testenv:crosspython2]
16-
basepython=python2
17-
deps =
18-
commands =
19-
virtualenv -p python3 {envtmpdir}/{envname}
20-
{envtmpdir}/{envname}/bin/python -V 2>&1 | grep "Python 3"
42+
commands = virtualenv -p python3 {envtmpdir}/{envname}
43+
{envtmpdir}/{envname}/bin/python -V 2>&1 | grep "Python 3"
44+
2145

22-
# Creating a python2 venv with a python3-based virtualenv
23-
[testenv:crosspython3]
24-
basepython=python3
46+
[testenv:cross_python3]
47+
description = test creating a python2 venv with a python3-based virtualenv
48+
basepython = python3
2549
deps =
26-
commands =
27-
virtualenv -p python2 {envtmpdir}/{envname}
28-
{envtmpdir}/{envname}/bin/python -V 2>&1 | grep "Python 2"
50+
commands = virtualenv -p python2 {envtmpdir}/{envname}
51+
{envtmpdir}/{envname}/bin/python -V 2>&1 | grep "Python 2"
2952

3053
[testenv:docs]
31-
deps =
32-
sphinx
33-
readme
34-
commands =
35-
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
36-
python setup.py check -m -r -s
54+
basepython = python3
55+
description = build documentation
56+
deps = sphinx
57+
commands = sphinx-build -d "{envtmpdir}/doctree" docs "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
58+
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'
59+
60+
[testenv:package_readme]
61+
description = check that the long description is valid (need for PyPi)
62+
deps = twine >= 1.12.1
63+
pip >= 18.0.0
64+
skip_install = true
65+
extras =
66+
commands = pip wheel -w {envtmpdir}/build --no-deps .
67+
twine check {envtmpdir}/build/*

0 commit comments

Comments
 (0)