Skip to content

Commit 3307ee0

Browse files
committed
Use uv-native environments in CI and get rid of requirements files.
1 parent 25ec0c2 commit 3307ee0

6 files changed

Lines changed: 878 additions & 454 deletions

File tree

‎.readthedocs.yaml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ build:
77
tools:
88
python: "3.13"
99

10+
jobs:
11+
post_create_environment:
12+
- pip install uv
13+
post_install:
14+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv sync --active --no-default-groups --group docs
15+
1016
sphinx:
1117
builder: dirhtml
1218
configuration: docs/conf.py
1319
fail_on_warning: true
1420

1521
formats: all
16-
17-
python:
18-
install:
19-
- requirements: docs/requirements.txt

‎docs/requirements.in‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎docs/requirements.txt‎

Lines changed: 0 additions & 114 deletions
This file was deleted.

‎noxfile.py‎

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,46 @@
1212
CHANGELOG = ROOT / "CHANGELOG.rst"
1313
DOCS = ROOT / "docs"
1414

15-
INSTALLABLE = [
15+
EXTRAS = [
1616
nox.param(value, id=name) for name, value in [
17-
("no-extras", str(ROOT)),
18-
("format", f"{ROOT}[format]"),
19-
("format-nongpl", f"{ROOT}[format-nongpl]"),
17+
("no-extras", None),
18+
("format", "format"),
19+
("format-nongpl", "format-nongpl"),
2020
]
2121
]
22-
REQUIREMENTS = dict(
23-
docs=DOCS / "requirements.txt",
24-
)
25-
REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other
26-
(path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values()
27-
]
2822

29-
SUPPORTED = ["pypy3.12", "3.12", "3.13", "3.14t", "3.14", "3.15t", "3.15"]
23+
SUPPORTED = [
24+
"pypy3.12",
25+
"3.12",
26+
"3.13",
27+
"3.14t",
28+
"3.14",
29+
"3.15t",
30+
"3.15",
31+
]
32+
# 3.15 is still a prerelease, so the non-test sessions run on the latest
33+
# stable interpreter until it's released.
3034
LATEST_STABLE = "3.14"
3135

32-
nox.options.default_venv_backend = "uv|virtualenv"
36+
nox.options.default_venv_backend = "uv"
3337
nox.options.sessions = []
3438

3539

40+
def install(session, *groups, extra=None):
41+
"""
42+
Install the project and the given dependency group(s) via ``uv sync``.
43+
"""
44+
session.run_install(
45+
"uv",
46+
"sync",
47+
*([] if extra is None else [f"--extra={extra}"]),
48+
"--no-default-groups",
49+
*(arg for group in groups for arg in ("--group", group)),
50+
f"--python={session.virtualenv.location}",
51+
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
52+
)
53+
54+
3655
def session(default=True, python=LATEST_STABLE, **kwargs): # noqa: D103
3756
def _session(fn):
3857
if default:
@@ -43,14 +62,14 @@ def _session(fn):
4362

4463

4564
@session(python=SUPPORTED)
46-
@nox.parametrize("installable", INSTALLABLE)
47-
def tests(session, installable):
65+
@nox.parametrize("extra", EXTRAS)
66+
def tests(session, extra):
4867
"""
4968
Run the test suite with a corresponding Python version.
5069
"""
5170
env = dict(JSON_SCHEMA_TEST_SUITE=str(ROOT / "json"))
5271

53-
session.install("--group=test", installable)
72+
install(session, "test", extra=extra)
5473

5574
if session.posargs and session.posargs[0] == "coverage":
5675
if len(session.posargs) > 1 and session.posargs[1] == "github":
@@ -130,7 +149,7 @@ def style(session):
130149
Check Python code style.
131150
"""
132151
session.install("ruff")
133-
session.run("ruff", "check", ROOT)
152+
session.run("ruff", "check", ROOT, __file__)
134153

135154

136155
@session()
@@ -163,7 +182,7 @@ def docs(session, builder):
163182
"""
164183
Build the documentation using a specific Sphinx builder.
165184
"""
166-
session.install("-r", REQUIREMENTS["docs"])
185+
install(session, "docs", extra="format")
167186
with TemporaryDirectory() as tmpdir_str:
168187
tmpdir = Path(tmpdir_str)
169188
argv = ["-n", "-T", "-W"]
@@ -196,38 +215,19 @@ def docs_style(session):
196215

197216

198217
@session(default=False)
199-
@nox.parametrize("installable", INSTALLABLE)
218+
@nox.parametrize("extra", EXTRAS)
200219
@nox.parametrize(
201220
"benchmark",
202221
[
203222
nox.param(each.stem, id=each.stem)
204223
for each in BENCHMARKS.glob("[!_]*.py")
205224
],
206225
)
207-
def bench(session, installable, benchmark):
226+
def bench(session, extra, benchmark):
208227
"""
209228
Run a performance benchmark.
210229
"""
211-
session.install("pyperf", installable)
230+
install("benchmarks", extra=extra)
212231
tmpdir = Path(session.create_tmp())
213232
output = tmpdir / f"bench-{benchmark}.json"
214233
session.run("python", BENCHMARKS / f"{benchmark}.py", "--output", output)
215-
216-
217-
@session(default=False)
218-
def requirements(session):
219-
"""
220-
Update the project's pinned requirements.
221-
222-
You should commit the result afterwards.
223-
"""
224-
if session.venv_backend == "uv":
225-
cmd = ["uv", "pip", "compile"]
226-
else:
227-
session.install("pip-tools")
228-
cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"]
229-
230-
for each, out in REQUIREMENTS_IN:
231-
# otherwise output files end up with silly absolute path comments...
232-
relative = each.relative_to(ROOT)
233-
session.run(*cmd, "--upgrade", "--output-file", out, relative)

‎pyproject.toml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ Source = "https://github.com/python-jsonschema/jsonschema"
8080

8181
[dependency-groups]
8282
test = ["virtue", "jsonpath-ng"]
83+
benchmarks = ["pyperf"]
84+
docs = [
85+
"furo",
86+
"lxml",
87+
"sphinx<9", # sphinx 9 appears to have issues I haven't diagnosed
88+
"sphinx-autoapi",
89+
"sphinx-autodoc-typehints",
90+
"sphinx-copybutton",
91+
"sphinx-json-schema-spec",
92+
"sphinxcontrib-spelling>5",
93+
"sphinxext-opengraph",
94+
]
8395

8496
[tool.hatch.metadata.hooks.fancy-pypi-readme]
8597
content-type = "text/x-rst"

0 commit comments

Comments
 (0)