diff options
author | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2023-01-01 05:50:20 +0100 |
---|---|---|
committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2023-01-01 05:51:16 +0100 |
commit | f865cce73c06bd1e8e04da26b59905a64eab140d (patch) | |
tree | 93e1facd5346a50e61fe9ac6afda566b9c540fde | |
parent | 8fcf5d3279adcaec8821ed5ed6f08d9b4a105992 (diff) | |
download | cherrypy-git-f865cce73c06bd1e8e04da26b59905a64eab140d.tar.gz |
🔧Implement build-dists and cleanup-dists @ tox
-rw-r--r-- | requirements/tox-build-dists.in | 1 | ||||
-rw-r--r-- | tox.ini | 76 |
2 files changed, 76 insertions, 1 deletions
diff --git a/requirements/tox-build-dists.in b/requirements/tox-build-dists.in new file mode 100644 index 00000000..27f5471d --- /dev/null +++ b/requirements/tox-build-dists.in @@ -0,0 +1 @@ +build ~= 0.9.0 @@ -1,6 +1,6 @@ [tox] envlist = python -minversion = 2.4 +minversion = 3.21.0 [testenv] usedevelop = True @@ -26,6 +26,19 @@ extras = 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 @@ -82,3 +95,64 @@ commands = -{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}' |