From 41f8b8aeb9f95f314c684a93ea01080c9a75ad42 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 19 Apr 2022 14:43:15 +0000 Subject: [PATCH] Various tox.ini improvements and cleanup Be more explicit about when we do and don't install the project in different testenvs by setting skip_install. This is currently redundant, but a sensible safeguard in case the implicit behavior from skipsdist and no usedevelop ever changes. Use shutil.rmtree() in place of calling `rm` so that we won't need an allowlist of executables outside the venv. Switch to tox's {envpython} replacement macro rather than invoking the interpreter by its assumed name, for improved portability. Inherit {[testenv]deps} in the deps list for any testenv which needs to extend it rather than duplicating its contents, for the sake of maintainability. Don't bother listing flake8 as an explicit dep in its testenv, since the flake8-bugbear plugin will pull it in as a requirement anyway. Update the DeprecationWarning comment about pyparsing now that the fix is available in 3.0.8 (but still not updated where it's being vendored). --- tox.ini | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/tox.ini b/tox.ini index e62c385..fddb29d 100644 --- a/tox.ini +++ b/tox.ini @@ -17,9 +17,8 @@ basepython = python3 # 'language_level' not set, using 2 for now (Py2). This will change in a # later release!" but this can't be matched by message because it has a comma # py311... pip._vendor.pyparsing.core and pkg_resources._vendor.pyparsing raise -# DeprecationWarning "module 'sre_constants' is deprecated" until a new -# release containing https://github.com/pyparsing/pyparsing/commit/3c03942 is -# vendored into pip and pkg_resources +# DeprecationWarning "module 'sre_constants' is deprecated" until +# pyparsing>=3.0.8 is vendored into pip and pkg_resources # py310... distutils.command.install raises DeprecationWarning "The # distutils.sysconfig module is deprecated, use sysconfig instead" but this # can't be matched by message because it contains a comma @@ -58,11 +57,13 @@ deps = {toxinidir} [testenv:bandit] description = check for potential security risks in source code +skip_install = True deps = bandit commands = bandit -r mudpy -x mudpy/tests {posargs} [testenv:codespell] description = find common spelling mistakes in code and documentation +skip_install = True deps = codespell commands = codespell {posargs} @@ -72,34 +73,32 @@ commands = mudpy {posargs} [testenv:dist] description = build release artifacts and check for conformance -allowlist_externals = rm +skip_install = True deps = build twine commands = - rm -fr {toxinidir}/dist - python -m build + {envpython} -c "import shutil; shutil.rmtree('{toxinidir}/dist', ignore_errors=True)" + {envpython} -m build twine check --strict {toxinidir}/dist/* [testenv:docs] # Build an sdist into a temporary location so we'll have AUTHORS and ChangeLog # files to include. description = generate hypertext documentation -allowlist_externals = rm deps = - {toxinidir} + {[testenv]deps} build sphinx commands = - rm -fr {toxinidir}/doc/build - python -m build --outdir={toxinidir}/doc/build/dist --sdist + {envpython} -c "import shutil; shutil.rmtree('{toxinidir}/doc/build', ignore_errors=True)" + {envpython} -m build --outdir={toxinidir}/doc/build/dist --sdist sphinx-build -W -d doc/build/doctrees -b html doc/source/ doc/build/html [testenv:flake8] description = style checks and static analysis of source code -deps = - flake8 - flake8-bugbear +skip_install = True +deps = flake8-bugbear commands = flake8 {posargs} [testenv:selftest_config] @@ -112,7 +111,7 @@ commands = mudpy_selftest etc/mudpy.yaml # them with the same style we enforce for those carried in the repository. description = test data files for correct syntax and formatting deps = - {toxinidir} + {[testenv]deps} yamllint commands = mudpy_selftest mudpy/tests/fixtures/test_daemon.yaml -- 2.11.0