1212CHANGELOG = ROOT / "CHANGELOG.rst"
1313DOCS = 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.
3034LATEST_STABLE = "3.14"
3135
32- nox .options .default_venv_backend = "uv|virtualenv "
36+ nox .options .default_venv_backend = "uv"
3337nox .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+
3655def 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 )
0 commit comments