CI: Add clean,build tox environments 10/71510/5
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 5 Apr 2023 19:19:04 +0000 (12:19 -0700)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 5 Apr 2023 22:21:05 +0000 (15:21 -0700)
Change-Id: Ide43cc73615ae67b1d423c83dc8d78e935d2470d
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
tox.ini

diff --git a/tox.ini b/tox.ini
index e9358b4..320cdc6 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -14,6 +14,26 @@ deps =
 commands =
     pytest --basetemp={envtmpdir} {posargs}
 
+
+[testenv:{build,clean}]
+description =
+    build: Build the package in isolation according to PEP517, see https://github.com/pypa/build
+    clean: Remove old distribution files and temporary build artifacts (./build and ./dist)
+# https://setuptools.pypa.io/en/stable/build_meta.html#how-to-use-it
+skip_install = True
+changedir = {toxinidir}
+deps =
+    build: build[virtualenv]
+passenv =
+    SETUPTOOLS_*
+commands =
+    clean: python -c 'import shutil; [shutil.rmtree(p, True) for p in ("build", "dist", "docs/_build")]'
+    clean: python -c 'import pathlib, shutil; [shutil.rmtree(p, True) for p in pathlib.Path("src").glob("*.egg-info")]'
+    build: python -m build {posargs}
+# By default, both `sdist` and `wheel` are built. If your sdist is too big or you don't want
+# to make it available, consider running: `tox -e build -- --wheel`
+
+
 [testenv:docs]
 basepython = python3
 deps =