diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:21:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:21:11 +0000 |
commit | cdb4a4e19b096cdbf1356e28287238122fc3599c (patch) | |
tree | c5ed3b2b40e4725bbaaae0710d1cbec21b23f3b0 /noxfile.py | |
parent | Initial commit. (diff) | |
download | python-installer-cdb4a4e19b096cdbf1356e28287238122fc3599c.tar.xz python-installer-cdb4a4e19b096cdbf1356e28287238122fc3599c.zip |
Adding upstream version 0.6.0+dfsg1.upstream/0.6.0+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'noxfile.py')
-rw-r--r-- | noxfile.py | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..eee4f7b --- /dev/null +++ b/noxfile.py @@ -0,0 +1,99 @@ +"""Development automation +""" +import os + +import nox + +nox.options.sessions = ["lint", "test", "doctest"] +nox.options.reuse_existing_virtualenvs = True + + +def _install_this_project_with_flit(session, *, extras=None, editable=False): + session.install("flit") + args = [] + if extras: + args.append("--extras") + args.append(",".join(extras)) + if editable: + args.append("--pth-file" if os.name == "nt" else "--symlink") + + session.run("flit", "install", "--deps=production", *args, silent=True) + + +@nox.session(python="3.11") +def lint(session): + session.install("pre-commit") + + if session.posargs: + args = session.posargs + elif "CI" in os.environ: + args = ["--show-diff-on-failure"] + else: + args = [] + + session.run("pre-commit", "run", "--all-files", *args) + + +@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"]) +def test(session): + _install_this_project_with_flit(session, editable=True) + session.install("-r", "tests/requirements.txt") + + htmlcov_output = os.path.join(session.virtualenv.location, "htmlcov") + + session.run( + "pytest", + "--cov=installer", + "--cov-fail-under=100", + "--cov-report=term-missing", + f"--cov-report=html:{htmlcov_output}", + "--cov-context=test", + "-n", + "auto", + *session.posargs, + ) + + +@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"]) +def doctest(session): + session.install(".") + session.install("-r", "docs/requirements.txt") + + session.run("sphinx-build", "-b", "doctest", "docs/", "build/doctest") + + +@nox.session(python="3.11", name="update-launchers") +def update_launchers(session): + session.install("httpx") + session.run("python", "tools/update_launchers.py") + + +# +# Documentation +# +@nox.session(python="3.11") +def docs(session): + _install_this_project_with_flit(session) + session.install("-r", "docs/requirements.txt") + + # Generate documentation into `build/docs` + session.run("sphinx-build", "-W", "-b", "html", "docs/", "build/docs") + + +@nox.session(name="docs-live", python="3.11") +def docs_live(session): + _install_this_project_with_flit(session, editable=True) + session.install("-r", "docs/requirements.txt") + session.install("sphinx-autobuild") + + # fmt: off + session.run( + "sphinx-autobuild", "docs/", "build/docs", + # Rebuild all files when rebuilding + "-a", + # Trigger rebuilds on code changes (for autodoc) + "--watch", "src/installer", + # Use a not-common high-numbered port + "--port", "8765", + ) + # fmt: on |