summaryrefslogtreecommitdiff
path: root/tox.ini
blob: a46eecf71de0dcac78ae62de410a0408d4527ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
[tox]
envlist = python
minversion = 3.21.0

[testenv]
usedevelop = True
commands =
    pytest {posargs}
    codecov -f coverage.xml -X gcov
passenv =
  WEBTEST_INTERACTIVE
  CI
  TRAVIS
  TRAVIS_*
  APPVEYOR
  APPVEYOR_*
  CIRCLECI
  CIRCLE_*
setenv =
    WEBTEST_INTERACTIVE=false
extras =
    testing
    routes_dispatcher
    memcached_session
whitelist_externals = mkdir

[python-cli-options]
byteerrors = -bb
bytewarnings = -b
# isolate = -I
# FIXME: Python 2 shim. Is this equivalent to the above?
isolate = -E -s


[dists]
setenv =
  PEP517_OUT_DIR = {env:PEP517_OUT_DIR:{toxinidir}{/}dist}


[testenv:cheroot-master]
deps = git+git://github.com/cherrypy/cheroot.git@master#egg=cheroot

[testenv:pre-commit]
deps =
    pre-commit
commands =
    {envpython} -m pre_commit run --show-diff-on-failure {posargs:--all-files}

    # Print out the advice 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:pre-commit-pep257]
deps = pre-commit
commands =
    pre-commit run --config .pre-commit-config-pep257.yaml --all-files {posargs}

[testenv:dist-check]
# ensure that package artifacts are installed as expected
usedevelop = False
commands =
    pytest tests/dist-check.py {posargs}

[testenv:setup-check]
extras =
    docs
usedevelop = False
commands =
    python -m setup check --metadata --restructuredtext --strict --verbose

[testenv:build-docs]
basepython = python3
extras =
    docs
    testing
changedir = docs
# FIXME: Add -W option below once this issue is addressed:
# https://github.com/jaraco/rst.linker/issues/7
# And once all other warnings are gone.
commands =
    {envpython} -m sphinx \
      -a \
      -j auto \
      -b html \
      --color \
      -n \
      -d "{toxinidir}/build/html_docs_doctree" \
      . \
      "{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:cleanup-dists]
description =
  Wipe the the dist{/} folder
# NOTE: `package_env = none` is needed so it's possible to use `--installpkg`
# NOTE: with the main `testenv`.
# Ref: https://github.com/tox-dev/tox/issues/2442
package_env = ❌ DUMMY NON-EXISTENT ENV NAME ❌
usedevelop = false
skip_install = true
deps =
setenv =
  {[dists]setenv}
commands_pre =
commands =
  {envpython} \
  {[python-cli-options]byteerrors} \
  {[python-cli-options]isolate} \
  -c \
    'import os, shutil, sys; dists_dir = os.getenv("PEP517_OUT_DIR"); shutil.rmtree(dists_dir, ignore_errors=True); sys.exit(os.path.exists(dists_dir))'


[testenv:build-dists]
allowlist_externals =
  env
description =
  Build dists and put them into
  the `{env:PEP517_OUT_DIR}{/}` folder
depends =
  cleanup-dists
platform = darwin|linux
# NOTE: The custom command is here to allow resetting the global
# NOTE: pip constraints env var.
isolated_build = true
# NOTE: `package_env = none` is needed so it's possible to use `--installpkg`
# NOTE: with the main `testenv`.
# Ref: https://github.com/tox-dev/tox/issues/2442
package_env = ❌ DUMMY NON-EXISTENT ENV NAME ❌
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
skip_install = true
deps =
  -rrequirements{/}tox-build-dists.in
passenv =
  PEP517_BUILD_ARGS
setenv =
  {[dists]setenv}
commands_pre =
commands =
  # Starting with build v0.5.0, it builds wheel from sdist
  # if no format arguments are passed. This makes sure that
  # wheels are not dependent on the Git repo or anything
  # external what may be missing from sdist.
  {envpython} \
    {[python-cli-options]byteerrors} \
    {[python-cli-options]isolate} \
    -m build \
    --outdir '{env:PEP517_OUT_DIR}{/}' \
    {posargs:{env:PEP517_BUILD_ARGS:}} \
    '{toxinidir}'