|
9 | 9 | DOCS = ROOT / "docs"
|
10 | 10 | PACKAGE = ROOT / "jsonschema_specifications"
|
11 | 11 |
|
| 12 | +REQUIREMENTS = dict( |
| 13 | + docs=DOCS / "requirements.txt", |
| 14 | +) |
| 15 | +REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other |
| 16 | + (path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values() |
| 17 | +] |
| 18 | + |
| 19 | +SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] |
| 20 | +LATEST = "3.12" # until 3.13 matures |
12 | 21 |
|
| 22 | +nox.options.default_venv_backend = "uv|virtualenv" |
13 | 23 | nox.options.sessions = []
|
14 | 24 |
|
15 | 25 |
|
16 |
| -def session(default=True, **kwargs): # noqa: D103 |
| 26 | +def session(default=True, python=LATEST, **kwargs): # noqa: D103 |
17 | 27 | def _session(fn):
|
18 | 28 | if default:
|
19 | 29 | nox.options.sessions.append(kwargs.get("name", fn.__name__))
|
20 |
| - return nox.session(**kwargs)(fn) |
| 30 | + return nox.session(python=python, **kwargs)(fn) |
21 | 31 |
|
22 | 32 | return _session
|
23 | 33 |
|
24 | 34 |
|
25 |
| -@session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"]) |
| 35 | +@session(python=SUPPORTED) |
26 | 36 | def tests(session):
|
27 | 37 | """
|
28 | 38 | Run the test suite with a corresponding Python version.
|
@@ -58,7 +68,7 @@ def style(session):
|
58 | 68 | Check Python code style.
|
59 | 69 | """
|
60 | 70 | session.install("ruff")
|
61 |
| - session.run("ruff", "check", ROOT) |
| 71 | + session.run("ruff", "check", ROOT, __file__) |
62 | 72 |
|
63 | 73 |
|
64 | 74 | @session()
|
@@ -88,7 +98,7 @@ def docs(session, builder):
|
88 | 98 | """
|
89 | 99 | Build the documentation using a specific Sphinx builder.
|
90 | 100 | """
|
91 |
| - session.install("-r", DOCS / "requirements.txt") |
| 101 | + session.install("-r", REQUIREMENTS["docs"]) |
92 | 102 | with TemporaryDirectory() as tmpdir_str:
|
93 | 103 | tmpdir = Path(tmpdir_str)
|
94 | 104 | argv = ["-n", "-T", "-W"]
|
@@ -123,15 +133,17 @@ def docs_style(session):
|
123 | 133 | @session(default=False)
|
124 | 134 | def requirements(session):
|
125 | 135 | """
|
126 |
| - Update the project's pinned requirements. Commit the result. |
| 136 | + Update the project's pinned requirements. |
| 137 | +
|
| 138 | + You should commit the result afterwards. |
127 | 139 | """
|
128 |
| - session.install("pip-tools") |
129 |
| - for each in [DOCS / "requirements.in"]: |
130 |
| - session.run( |
131 |
| - "pip-compile", |
132 |
| - "--resolver", |
133 |
| - "backtracking", |
134 |
| - "--strip-extras", |
135 |
| - "-U", |
136 |
| - each.relative_to(ROOT), |
137 |
| - ) |
| 140 | + if session.venv_backend == "uv": |
| 141 | + cmd = ["uv", "pip", "compile"] |
| 142 | + else: |
| 143 | + session.install("pip-tools") |
| 144 | + cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"] |
| 145 | + |
| 146 | + for each, out in REQUIREMENTS_IN: |
| 147 | + # otherwise output files end up with silly absolute path comments... |
| 148 | + relative = each.relative_to(ROOT) |
| 149 | + session.run(*cmd, "--upgrade", "--output-file", out, relative) |
0 commit comments