tox.ini
[tox]
project = swcheckin
envlist = python
isolated_build = True
requires =
setuptools >= 41.4.0
pip >= 19.3.0
[testenv]
basepython = python3
isolated_build = true
usedevelop = False
extras =
testing
commands =
{envpython} -m pytest {posargs:--cov-report=term-missing:skip-covered}
passenv =
CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437
HOME
REQUESTS_CA_BUNDLE # https proxies
SSL_CERT_FILE # https proxies
TRAVIS
TRAVIS_*
# recreate = True
[testenv:build-dists]
description =
Build dists with PEP 517 and save them in the dist/ dir
basepython = python3
skip_install = true
passenv =
{[testenv]passenv}
PYPI_UPLOAD
deps =
pep517 >= 0.5.0
setenv =
PYPI_UPLOAD = true
commands =
{envpython} -c 'import os.path, shutil, sys; \
dist_dir = os.path.join("{toxinidir}", "dist"); \
os.path.isdir(dist_dir) or sys.exit(0); \
print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \
shutil.rmtree(dist_dir)'
{envpython} -m pep517.build \
--source \
--binary \
--out-dir {toxinidir}/dist/ \
{toxinidir}
whitelist_externals =
rm
[testenv:pre-commit]
isolated_build = true
deps =
pre-commit>=1.20.0
pylint
commands =
{envpython} -m pre_commit run --show-diff-on-failure {posargs:--all-files}
# Print out the advise of how to install pre-commit from this env into Git:
-{envpython} -c \
'cmd = "{envpython} -m pre_commit install"; scr_width = len(cmd) + 10; sep = "=" * scr_width; cmd_str = " $ " + cmd; '\
'print("\n" + sep + "\nTo install pre-commit hooks into the Git repo, run:\n\n" + cmd_str + "\n\n" + sep + "\n")'
[testenv:report]
depends = clean
deps = coverage
skip_install = true
commands =
coverage html
coverage xml
coverage report
[testenv:clean]
skip_install= true
deps = coverage
commands = coverage erase
[testenv:build-docs]
basepython = python3
isolated_build = true
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
## don't install swcheckin itself in this env
#skip_install = true
#usedevelop = true
extras =
docs
# testing
#deps =
# pip >= 18
changedir = docs
commands =
# FIXME: Add -W option below once all other warnings are gone
{envpython} -m sphinx \
-j auto \
-b html \
--color \
-n \
-d "{toxinidir}/build/.doctrees" \
. \
"{toxinidir}/build/html"
# Print out the output docs dir and a way to serve html:
-{envpython} -c \
'import pathlib; docs_dir = pathlib.Path(r"{toxinidir}") / "build" / "html"; index_file = docs_dir / "index.html"; '\
'print("\n" + "=" * 120 + f"\n\nDocumentation available under `file://\{index_file\}`\n\nTo serve docs, use `python3 -m http.server --directory \{docs_dir\} 0`\n\n" + "=" * 120)'
[testenv:metadata-validation]
description =
Verify that dists under the dist/ dir have valid metadata
depends = build-dists
deps =
twine
skip_install = true
# Ref: https://twitter.com/di_codes/status/1044358639081975813
commands =
twine check {toxinidir}/dist/*