From ce706d2e655c3b4b43d783af25fbc8f61776e1ff Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Fri, 12 Apr 2024 23:03:21 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Adopt=20`uv`=20in=20CI=20(#444)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR updates the CI configuration to use uv by Astral (the creators of ruff), which is an extremely fast Python package installer and resolver, written in Rust. It is sesigned as a drop-in replacement for common pip and pip-tools workflows. See https://github.com/astral-sh/uv Similar to ruff, it is extremely fast and in very active development. This should speed up any of the Python-based CI runs without much confirguration overhead. This PR refactors the `minimums` check to make use of `uv`'s `--resolution=lowest-direct" feature. This allows us to completely get rid of the `constraints.txt` file. Furthermore, it makes use of the new versions of `mqt-core`'s reusable workflows. ## Checklist: - [x] The pull request only contains commits that are related to it. - [x] I have added appropriate tests and documentation. - [x] I have made sure that all CI jobs on GitHub pass. - [x] The pull request introduces no new warnings and follows the project's style guidelines. --------- Signed-off-by: burgholzer --- .github/codecov.yml | 2 +- extern/mqt-core | 2 +- noxfile.py | 27 +++++++++++++++++---------- pyproject.toml | 2 +- test/python/constraints.txt | 14 -------------- 5 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 test/python/constraints.txt diff --git a/.github/codecov.yml b/.github/codecov.yml index 356666bf7..f7313574e 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -30,7 +30,7 @@ flag_management: - name: python paths: - "src/mqt/**/*.py" - after_n_builds: 3 + after_n_builds: 12 statuses: - type: project threshold: 0.5% diff --git a/extern/mqt-core b/extern/mqt-core index 09cfd937b..63fdf109e 160000 --- a/extern/mqt-core +++ b/extern/mqt-core @@ -1 +1 @@ -Subproject commit 09cfd937be48f0913302f233f7b6ce76de587657 +Subproject commit 63fdf109ed86fd3320989cd34bb7c155afaf4532 diff --git a/noxfile.py b/noxfile.py index f79a626f5..796e37174 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,6 +4,7 @@ import argparse import os +import shutil import sys from typing import TYPE_CHECKING @@ -12,6 +13,9 @@ if TYPE_CHECKING: from collections.abc import Sequence +nox.needs_version = ">=2024.3.2" +nox.options.default_venv_backend = "uv|virtualenv" + nox.options.sessions = ["lint", "tests"] PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"] @@ -46,6 +50,11 @@ def _run_tests( if os.environ.get("CI", None) and sys.platform == "win32": env["SKBUILD_CMAKE_ARGS"] = "-T ClangCL" + if shutil.which("cmake") is None and shutil.which("cmake3") is None: + session.install("cmake") + if shutil.which("ninja") is None: + session.install("ninja") + _extras = ["test", *extras] if "--cov" in posargs: _extras.append("coverage") @@ -63,29 +72,27 @@ def tests(session: nox.Session) -> None: _run_tests(session) -@nox.session() +@nox.session(reuse_venv=True, venv_backend="uv") def minimums(session: nox.Session) -> None: """Test the minimum versions of dependencies.""" _run_tests( session, - install_args=["--constraint=test/python/constraints.txt"], + install_args=["--resolution=lowest-direct"], run_args=["-Wdefault"], + extras=["qiskit", "evaluation"], ) - session.run("pip", "list") + session.run("uv", "pip", "list") @nox.session(reuse_venv=True) def docs(session: nox.Session) -> None: - """Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links.""" + """Build the docs. Use "--non-interactive" to avoid serving. Pass "-b linkcheck" to check links.""" parser = argparse.ArgumentParser() - parser.add_argument("--serve", action="store_true", help="Serve after building") parser.add_argument("-b", dest="builder", default="html", help="Build target (default: html)") args, posargs = parser.parse_known_args(session.posargs) - if args.builder != "html" and args.serve: - session.error("Must not specify non-HTML builder with --serve") - - extra_installs = ["sphinx-autobuild"] if args.serve else [] + serve = args.builder == "html" and session.interactive + extra_installs = ["sphinx-autobuild"] if serve else [] session.install(*BUILD_REQUIREMENTS, *extra_installs) session.install("--no-build-isolation", "-ve.[docs]") session.chdir("docs") @@ -103,7 +110,7 @@ def docs(session: nox.Session) -> None: *posargs, ) - if args.serve: + if serve: session.run("sphinx-autobuild", *shared_args) else: session.run("sphinx-build", "--keep-going", *shared_args) diff --git a/pyproject.toml b/pyproject.toml index 62395e1aa..7123265f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ dynamic = ["version"] [project.optional-dependencies] test = ["pytest>=7", "mqt.qcec>=2.4.5", "mqt.qmap[visualization]"] -coverage = ["mqt.qmap[test]", "pytest-cov"] +coverage = ["mqt.qmap[test]", "pytest-cov>=4"] docs = [ "furo>=2023.08.17", "sphinx", diff --git a/test/python/constraints.txt b/test/python/constraints.txt deleted file mode 100644 index d7bc2a0c9..000000000 --- a/test/python/constraints.txt +++ /dev/null @@ -1,14 +0,0 @@ -scikit-build-core==0.8.1 -setuptools-scm==7.0.0 -pybind11==2.12.0 -pytest==7.0.0 -importlib_resources==5.0.0 -typing_extensions==4.6.0 -qiskit==1.0.0 -rustworkx==0.14.0 -mqt.qcec==2.4.5 -distinctipy==1.2.2 -plotly==5.15.0 -networkx==2.5 -walkerlayout==1.0.2 -ipywidgets==7.6.5