Skip to content

Commit f0f9764

Browse files
authored
Merge pull request #562 from webknjaz/maintenance/tox-isolated-and-optimized-python
Run Python commands in tox in isolated and strict mode
2 parents 4ba0db1 + 787ffb5 commit f0f9764

File tree

1 file changed

+72
-17
lines changed

1 file changed

+72
-17
lines changed

tox.ini

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@ minversion = 3.14.0
1212
deps =
1313
-rrequirements/tests.in
1414
commands_pre =
15-
{envpython} -m \
15+
{envpython} \
16+
{[python-cli-options]byteerrors} \
17+
{[python-cli-options]isolate} \
18+
-m \
1619
OpenSSL.debug
1720
commands =
18-
{envpython} -m \
21+
{envpython} \
22+
{[python-cli-options]byteerrors} \
23+
{[python-cli-options]isolate} \
24+
-m \
1925
pytest \
2026
{tty:--color=yes} \
2127
{posargs:}
2228
install_command =
2329
{envpython} \
30+
{[python-cli-options]byteerrors} \
31+
{[python-cli-options]isolate} \
2432
{toxinidir}/bin/pip-wrapper \
2533
'{envname}' \
2634
'{toxinidir}/requirements/' \
@@ -48,6 +56,14 @@ setenv =
4856
WEBTEST_INTERACTIVE=false
4957

5058

59+
[python-cli-options]
60+
byteerrors = -bb
61+
bytewarnings = -b
62+
# isolate = -I
63+
# FIXME: Python 2 shim. Is this equivalent to the above?
64+
isolate = -E -s
65+
66+
5167
[dists]
5268
setenv =
5369
PIP_CONSTRAINT = {toxinidir}/requirements/dist-build-constraints.txt
@@ -71,7 +87,10 @@ commands =
7187
# FIXME: instead of `{toxworkdir}/.tmp` that was added in tox v3.16.1.
7288
# NOTE: The last tox supporting Python 3.4 is 3.14.0
7389
# -d "{temp_dir}/.doctrees" \
74-
{envpython} -m sphinx \
90+
{envpython} \
91+
{[python-cli-options]byteerrors} \
92+
{[python-cli-options]isolate} \
93+
-m sphinx \
7594
-j auto \
7695
-b html \
7796
{tty:--color} \
@@ -83,7 +102,10 @@ commands =
83102
"{envdir}/docs_out"
84103

85104
# Print out the output docs dir and a way to serve html:
86-
-{envpython} -c\
105+
-{envpython} \
106+
{[python-cli-options]byteerrors} \
107+
{[python-cli-options]isolate} \
108+
-c\
87109
'import pathlib;\
88110
docs_dir = pathlib.Path(r"{envdir}") / "docs_out";\
89111
index_file = docs_dir / "index.html";\
@@ -106,8 +128,11 @@ commands =
106128
-git fetch --unshallow
107129
-git fetch --tags
108130

109-
# Spellcheck docs site:
110-
python -m sphinx \
131+
# Doctest docs site:
132+
{envpython} \
133+
{[python-cli-options]byteerrors} \
134+
{[python-cli-options]isolate} \
135+
-m sphinx \
111136
-j auto \
112137
-a -n -W \
113138
--keep-going \
@@ -129,8 +154,11 @@ commands =
129154
-git fetch --unshallow
130155
-git fetch --tags
131156

132-
# Spellcheck docs site:
133-
python -m sphinx \
157+
# Linkcheck docs site:
158+
{envpython} \
159+
{[python-cli-options]byteerrors} \
160+
{[python-cli-options]isolate} \
161+
-m sphinx \
134162
-j auto \
135163
-a -n -W \
136164
--keep-going \
@@ -153,7 +181,10 @@ commands =
153181
-git fetch --tags
154182

155183
# Spellcheck docs site:
156-
python -m sphinx \
184+
{envpython} \
185+
{[python-cli-options]byteerrors} \
186+
{[python-cli-options]isolate} \
187+
-m sphinx \
157188
-j auto \
158189
-a -n -W \
159190
--keep-going \
@@ -179,8 +210,14 @@ deps =
179210
usedevelop = False
180211
commands_pre =
181212
commands =
182-
python -m twine check .tox/dist/*
183-
python -m setuptools_scm ls
213+
{envpython} \
214+
{[python-cli-options]byteerrors} \
215+
{[python-cli-options]isolate} \
216+
-m twine check .tox/dist/*
217+
{envpython} \
218+
{[python-cli-options]byteerrors} \
219+
{[python-cli-options]isolate} \
220+
-m setuptools_scm ls
184221

185222

186223
[testenv:cleanup-dists]
@@ -193,7 +230,10 @@ setenv =
193230
{[dists]setenv}
194231
commands_pre =
195232
commands =
196-
{envpython} -c \
233+
{envpython} \
234+
{[python-cli-options]byteerrors} \
235+
{[python-cli-options]isolate} \
236+
-c \
197237
'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))'
198238

199239

@@ -211,6 +251,8 @@ platform = darwin|linux
211251
install_command =
212252
env PIP_CONSTRAINT= \
213253
{envpython} \
254+
{[python-cli-options]byteerrors} \
255+
{[python-cli-options]isolate} \
214256
{toxinidir}/bin/pip-wrapper \
215257
'{envname}' \
216258
'{toxinidir}/requirements/' \
@@ -231,7 +273,10 @@ commands =
231273
# if no format arguments are passed. This makes sure that
232274
# wheels are not dependent on the Git repo or anything
233275
# external what may be missing from sdist.
234-
{envpython} -m build \
276+
{envpython} \
277+
{[python-cli-options]byteerrors} \
278+
{[python-cli-options]isolate} \
279+
-m build \
235280
--outdir '{env:PEP517_OUT_DIR}/' \
236281
{posargs:{env:PEP517_BUILD_ARGS:}} \
237282
'{toxinidir}'
@@ -251,7 +296,10 @@ commands_pre =
251296
setenv =
252297
{[dists]setenv}
253298
commands =
254-
{envpython} -m twine check \
299+
{envpython} \
300+
{[python-cli-options]byteerrors} \
301+
{[python-cli-options]isolate}
302+
-m twine check \
255303
--strict \
256304
{env:PEP517_OUT_DIR}/*
257305

@@ -267,6 +315,13 @@ setenv =
267315
TWINE_USERNAME = {env:TWINE_USERNAME:__token__}
268316
commands_pre =
269317
commands =
270-
python -c "import path; path.Path('dist').rmtree_p()"
271-
python -m pep517.build .
272-
python -m twine upload dist/*
318+
{envpython} \
319+
{[python-cli-options]byteerrors} \
320+
{[python-cli-options]isolate} \
321+
-c "import path; path.Path('dist').rmtree_p()"
322+
{envpython} \
323+
{[python-cli-options]byteerrors} \
324+
{[python-cli-options]isolate} -m pep517.build .
325+
{envpython} \
326+
{[python-cli-options]byteerrors} \
327+
{[python-cli-options]isolate} -m twine upload dist/*

0 commit comments

Comments
 (0)