Skip to content

Commit ad88108

Browse files
✨ Introduce Hatchling and dependency-groups (#530)
resolved #524 and resolves #525 --------- Signed-off-by: burgholzer <burgholzer@me.com> Co-authored-by: burgholzer <burgholzer@me.com>
1 parent 8f3e6e4 commit ad88108

6 files changed

Lines changed: 250 additions & 146 deletions

File tree

.github/renovate.json5

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
lockFileMaintenance: {
1010
"enabled": true,
11-
// "automerge": true, disabled due to endless update loops caused by setuptools_scm
11+
"automerge": true,
1212
},
1313
configMigration: true,
1414
labels: ["dependencies"],
@@ -33,6 +33,13 @@
3333
"description": "Automerge patch updates",
3434
"matchUpdateTypes": ["patch"],
3535
"automerge": true
36+
},
37+
{
38+
description: "Automerge minor updates for stable dependencies",
39+
matchManagers: ["pep621", "pre-commit"],
40+
matchUpdateTypes: ["minor", "patch"],
41+
matchCurrentVersion: "!/^0/",
42+
automerge: true
3643
}
3744
]
3845
}

.pre-commit-config.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@ repos:
8282
rev: v1.15.0
8383
hooks:
8484
- id: mypy
85-
files: ^(src/mqt|test/python)
85+
files: ^(src/mqt|test/python|noxfile.py)
8686
args: []
8787
additional_dependencies:
8888
- importlib_resources
8989
- numpy
90+
- nox
9091
- pytest
91-
- types-setuptools
92-
- types-requests
93-
- types-tqdm
9492

9593
# Check for spelling
9694
- repo: https://github.com/crate-ci/typos

.readthedocs.yaml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
version: 2
22

3-
submodules:
4-
include: all
5-
recursive: true
3+
formats:
4+
- htmlzip
65

76
build:
8-
os: ubuntu-22.04
7+
os: ubuntu-24.04
98
tools:
10-
python: "3.11"
9+
python: "3.12"
1110
jobs:
1211
post_checkout:
1312
# Skip docs build if the commit message contains "skip ci"
@@ -18,13 +17,17 @@ build:
1817
then
1918
exit 183;
2019
fi
21-
22-
sphinx:
23-
configuration: docs/conf.py
24-
25-
python:
26-
install:
27-
- method: pip
28-
path: .
29-
extra_requirements:
30-
- docs
20+
# Unshallow the git clone and fetch tags to get proper version information
21+
- git fetch --unshallow --tags
22+
pre_build:
23+
# Set up uv
24+
- asdf plugin add uv
25+
- asdf install uv latest
26+
- asdf global uv latest
27+
build:
28+
html:
29+
- uv run --frozen --no-dev --group docs -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
30+
htmlzip:
31+
- uv run --frozen --no-dev --group docs -m sphinx -T -b dirhtml -d docs/_build/doctrees -D language=en docs docs/_build/dirhtml
32+
- mkdir -p $READTHEDOCS_OUTPUT/htmlzip
33+
- zip -r $READTHEDOCS_OUTPUT/htmlzip/html.zip docs/_build/dirhtml/*

noxfile.py

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@
1414

1515

1616
nox.needs_version = ">=2024.3.2"
17-
nox.options.default_venv_backend = "uv|virtualenv"
17+
nox.options.default_venv_backend = "uv"
1818

19+
nox.options.sessions = ["lint", "tests", "minimums"]
1920

2021
PYTHON_ALL_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
2122

22-
BUILD_REQUIREMENTS = [
23-
"setuptools>=66.1",
24-
"setuptools_scm>=8.1",
25-
"wheel>=0.40",
26-
]
27-
2823
if os.environ.get("CI", None):
2924
nox.options.error_on_missing_interpreters = True
3025

@@ -43,20 +38,22 @@ def _run_tests(
4338
*,
4439
install_args: Sequence[str] = (),
4540
run_args: Sequence[str] = (),
46-
extras: Sequence[str] = (),
4741
) -> None:
48-
posargs = list(session.posargs)
49-
env = {"PIP_DISABLE_PIP_VERSION_CHECK": "1"}
50-
51-
extras_ = ["test", *extras]
52-
if "--cov" in posargs:
53-
extras_.append("coverage")
54-
posargs.append("--cov-config=pyproject.toml")
55-
56-
session.install(*BUILD_REQUIREMENTS, *install_args, env=env)
57-
install_arg = f"-ve.[{','.join(extras_)}]"
58-
session.install("--no-build-isolation", install_arg, *install_args, env=env)
59-
session.run("pytest", *run_args, *posargs, env=env)
42+
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
43+
44+
session.run(
45+
"uv",
46+
"run",
47+
"--no-dev",
48+
"--group",
49+
"test",
50+
*install_args,
51+
"pytest",
52+
*run_args,
53+
*session.posargs,
54+
"--cov-config=pyproject.toml",
55+
env=env,
56+
)
6057

6158

6259
@nox.session(reuse_venv=True, python=PYTHON_ALL_VERSIONS)
@@ -73,7 +70,9 @@ def minimums(session: nox.Session) -> None:
7370
install_args=["--resolution=lowest-direct"],
7471
run_args=["-Wdefault"],
7572
)
76-
session.run("uv", "pip", "list")
73+
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
74+
session.run("uv", "tree", "--frozen", env=env)
75+
session.run("uv", "lock", "--refresh", env=env)
7776

7877

7978
@nox.session(reuse_venv=True)
@@ -84,25 +83,27 @@ def docs(session: nox.Session) -> None:
8483
args, posargs = parser.parse_known_args(session.posargs)
8584

8685
serve = args.builder == "html" and session.interactive
87-
extra_installs = ["sphinx-autobuild"] if serve else []
88-
session.install(*BUILD_REQUIREMENTS, *extra_installs)
89-
session.install("--no-build-isolation", "-ve.[docs]")
90-
session.chdir("docs")
91-
92-
if args.builder == "linkcheck":
93-
session.run("sphinx-build", "-b", "linkcheck", ".", "_build/linkcheck", *posargs)
94-
return
86+
if serve:
87+
session.install("sphinx-autobuild")
9588

96-
shared_args = (
89+
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
90+
shared_args = [
9791
"-n", # nitpicky mode
9892
"-T", # full tracebacks
9993
f"-b={args.builder}",
100-
".",
101-
f"_build/{args.builder}",
94+
"docs",
95+
f"docs/_build/{args.builder}",
10296
*posargs,
97+
]
98+
99+
session.run(
100+
"uv",
101+
"run",
102+
"--no-dev",
103+
"--group",
104+
"docs",
105+
"--frozen",
106+
"sphinx-autobuild" if serve else "sphinx-build",
107+
*shared_args,
108+
env=env,
103109
)
104-
105-
if serve:
106-
session.run("sphinx-autobuild", "--ignore", "**jupyter**", *shared_args)
107-
else:
108-
session.run("sphinx-build", "--keep-going", *shared_args)

pyproject.toml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[build-system]
22
requires = [
3-
"setuptools>=66.1",
4-
"setuptools_scm>=8.1",
3+
"hatchling>=1.27.0",
4+
"hatch-vcs>=0.4.0"
55
]
6-
build-backend = "setuptools.build_meta"
6+
build-backend = "hatchling.build"
77

88
[project]
99
name = "mqt.bench"
@@ -50,25 +50,32 @@ classifiers = [
5050
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
5151
]
5252

53-
[project.optional-dependencies]
54-
test = ["pytest>=7.2", "pytest-console-scripts>=1.4"]
55-
coverage = ["mqt.bench[test]", "pytest-cov>=4"]
53+
[dependency-groups]
54+
test = [
55+
"pytest>=8.3.5",
56+
"pytest-console-scripts>=1.4.1",
57+
"pytest-cov>=6.1.1",
58+
]
5659
docs = [
57-
"furo>=2023.9.10",
58-
"qiskit[visualization]",
59-
"setuptools-scm>=8.1",
60-
"sphinx_design>=0.6",
61-
"sphinx-autoapi>=3",
62-
"sphinx-copybutton>=0.5",
63-
"sphinxcontrib-bibtex>=2.4.2",
64-
"sphinxcontrib-svg2pdfconverter>=1.2",
65-
"sphinxext-opengraph>=0.9",
66-
"ipython",
67-
"ipykernel",
68-
"nbsphinx",
69-
"sphinx-autodoc-typehints",
60+
"furo>=2024.8.6",
61+
"qiskit[visualization]>=1.2.1",
62+
"setuptools-scm>=8.2",
63+
"sphinx_design>=0.6.1",
64+
"sphinx-autoapi>=3.6.0",
65+
"sphinx-copybutton>=0.5.2",
66+
"sphinxcontrib-bibtex>=2.6.3",
67+
"sphinxcontrib-svg2pdfconverter>=1.3.0",
68+
"sphinxext-opengraph>=0.10.0",
69+
"sphinx>=8.1.3; python_version >= '3.10'",
70+
"sphinx>=8.2.3; python_version >= '3.11'",
71+
"ipykernel>=6.29.5",
72+
"nbsphinx>=0.9.6",
73+
"sphinx-autodoc-typehints>=2.3.0",
74+
]
75+
dev = [
76+
{include-group = "test"},
77+
{include-group = "docs"},
7078
]
71-
dev = ["mqt.bench[coverage, docs]"]
7279

7380
[project.scripts]
7481
"create_mqt_bench_zip" = "mqt.bench.utils:create_zip_file"
@@ -81,7 +88,14 @@ Homepage = "https://github.com/cda-tum/mqtbench"
8188
Discussions = "https://github.com/cda-tum/mqtbench/discussions"
8289
Research = "https://www.cda.cit.tum.de/research/quantum/"
8390

84-
[tool.setuptools_scm]
91+
[tool.hatch.build.targets.wheel]
92+
packages = ["src/mqt"]
93+
94+
[tool.hatch.version]
95+
source = "vcs"
96+
97+
[tool.hatch.build.hooks.vcs]
98+
version-file = "src/mqt/bench/_version.py"
8599

86100
[tool.pytest.ini_options]
87101
minversion = "7.2"

0 commit comments

Comments
 (0)