1212REQUIREMENTS = dict (
1313 tests = ROOT / "test-requirements.txt" ,
1414)
15- REQUIREMENTS_IN = {
16- path .parent / f"{ path .stem } .in" for path in REQUIREMENTS .values ()
17- }
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+ ]
1818
19-
20- SUPPORTED = ["pypy3.10" , "3.10" , "3.11" , "3.12" ]
19+ SUPPORTED = ["pypy3.10" , "3.10" , "3.11" , "3.12" , "3.13" ]
2120LATEST = SUPPORTED [- 1 ]
2221
22+ nox .options .default_venv_backend = "uv|virtualenv"
2323nox .options .sessions = []
2424
2525
@@ -35,7 +35,7 @@ def _session(fn):
3535@session (python = SUPPORTED )
3636def tests (session ):
3737 """
38- Run the test suite.
38+ Run the test suite with a corresponding Python version .
3939 """
4040 session .install ("-r" , REQUIREMENTS ["tests" ])
4141
@@ -60,7 +60,7 @@ def tests(session):
6060 stdout = summary ,
6161 )
6262 else :
63- session .run ("python" , "-m" , " pytest" , * session .posargs , PACKAGE )
63+ session .run ("pytest" , * session .posargs , PACKAGE )
6464
6565
6666@session (python = SUPPORTED )
@@ -77,9 +77,15 @@ def build(session):
7777 """
7878 Build a distribution suitable for PyPI and check its validity.
7979 """
80- session .install ("build" , "twine" )
80+ session .install ("build[uv] " , "twine" )
8181 with TemporaryDirectory () as tmpdir :
82- session .run ("python" , "-m" , "build" , ROOT , "--outdir" , tmpdir )
82+ session .run (
83+ "pyproject-build" ,
84+ "--installer=uv" ,
85+ ROOT ,
86+ "--outdir" ,
87+ tmpdir ,
88+ )
8389 session .run ("twine" , "check" , "--strict" , tmpdir + "/*" )
8490
8591
@@ -95,33 +101,35 @@ def secrets(session):
95101@session (tags = ["style" ])
96102def style (session ):
97103 """
98- Check for coding style.
104+ Check Python code style.
99105 """
100106 session .install ("ruff" )
101- session .run ("ruff" , "check" , ROOT )
107+ session .run ("ruff" , "check" , ROOT , __file__ )
102108
103109
104110@session ()
105111def typing (session ):
106112 """
107- Statically check typing annotations .
113+ Check static typing.
108114 """
109115 session .install ("pyright" , ROOT )
110- session .run ("pyright" , PACKAGE )
116+ session .run ("pyright" , * session . posargs , PACKAGE )
111117
112118
113119@session (default = False )
114120def requirements (session ):
115121 """
116- Update requirements files.
122+ Update the project's pinned requirements.
123+
124+ You should commit the result afterwards.
117125 """
118- session .install ( "pip-tools" )
119- for each in REQUIREMENTS_IN :
120- session . run (
121- "pip-compile" ,
122- "--resolver" ,
123- "backtracking" ,
124- "--strip-extras" ,
125- "-U" ,
126- each .relative_to (ROOT ),
127- )
126+ if session .venv_backend == "uv" :
127+ cmd = [ "uv" , "pip" , "compile" ]
128+ else :
129+ session . install ( "pip-tools" )
130+ cmd = [ "pip-compile" , "--resolver" , "backtracking" , "--strip-extras" ]
131+
132+ for each , out in REQUIREMENTS_IN :
133+ # otherwise output files end up with silly absolute path comments...
134+ relative = each .relative_to (ROOT )
135+ session . run ( * cmd , "--upgrade" , "--output-file" , out , relative )
0 commit comments