1+ # /// script
2+ # dependencies = ["nox>=2025.2.9"]
3+ # ///
4+
15import argparse
26import re
37from pathlib import Path
48
59import nox
610
7- nox .needs_version = ">=2024.3.2 "
11+ nox .needs_version = ">=2025.2.9 "
812nox .options .default_venv_backend = "uv|virtualenv"
9- nox .options .sessions = ["lint" , "build" , "tests" ]
1013
1114BUILD_ENV = {
1215 "MACOSX_DEPLOYMENT_TARGET" : "10.10" ,
1316 "ARCHFLAGS" : "-arch x86_64 -arch arm64" ,
1417}
1518
16- built = ""
19+ wheel = ""
1720
1821
1922@nox .session
2023def build (session : nox .Session ) -> str :
2124 """
22- Make an SDist and a wheel. Only runs once.
25+ Make an SDist and a wheel.
2326 """
24- global built
25- if not built :
26- session . log (
27- "The files produced locally by this job are not intended to be redistributable"
28- )
29- session .install ( "build" )
30- tmpdir = session . create_tmp ( )
31- session . run ( "python" , "-m" , "build" , "--outdir" , tmpdir , env = BUILD_ENV )
32- ( wheel_path ,) = Path (tmpdir ).glob ("*.whl " )
33- ( sdist_path ,) = Path (tmpdir ). glob ( "*.tar.gz" )
34- Path ( "dist" ). mkdir ( exist_ok = True )
35- wheel_path .rename (f"dist/{ wheel_path .name } " )
36- sdist_path . rename ( f"dist/ { sdist_path . name } " )
37- built = wheel_path . name
38- return built
27+ session . log (
28+ "The files produced locally by this job are not intended to be redistributable"
29+ )
30+ extra = [ "--installer=uv" ] if session . venv_backend == "uv" else []
31+ session . install ( "build" )
32+ tmpdir = session .create_tmp ( )
33+ session . run ( "python" , "-m" , "build" , "--outdir" , tmpdir , * extra , env = BUILD_ENV )
34+ ( wheel_path ,) = Path ( tmpdir ). glob ( "*.whl" )
35+ ( sdist_path ,) = Path (tmpdir ).glob ("*.tar.gz " )
36+ Path ("dist" ). mkdir ( exist_ok = True )
37+ wheel_path . rename ( f "dist/ { wheel_path . name } " )
38+ sdist_path .rename (f"dist/{ sdist_path .name } " )
39+
40+ global wheel
41+ wheel = f"dist/ { wheel_path . name } "
3942
4043
4144@nox .session
@@ -47,32 +50,34 @@ def lint(session: nox.Session) -> str:
4750 session .run ("pre-commit" , "run" , "-a" )
4851
4952
50- @nox .session
53+ @nox .session ( requires = [ "build" ])
5154def tests (session : nox .Session ) -> str :
5255 """
5356 Run the tests.
5457 """
55- wheel = build (session )
56- session .install (f"./dist/{ wheel } [test]" )
58+ pyproject = nox .project .load_toml ("pyproject.toml" )
59+ deps = nox .project .dependency_groups (pyproject , "test" )
60+ session .install (wheel , * deps )
5761 session .run ("pytest" , * session .posargs )
5862
5963
60- @nox .session (reuse_venv = True )
64+ @nox .session (reuse_venv = True , default = False )
6165def docs (session : nox .Session ) -> None :
6266 """
6367 Build the docs. Pass "--non-interactive" to avoid serve. Pass "-- -b linkcheck" to check links.
6468 """
69+ pyproject = nox .project .load_toml ("pyproject.toml" )
70+ deps = nox .project .dependency_groups (pyproject , "docs" )
6571
6672 parser = argparse .ArgumentParser ()
67- parser .add_argument ("--serve" , action = "store_true" , help = "Serve after building" )
6873 parser .add_argument (
6974 "-b" , dest = "builder" , default = "html" , help = "Build target (default: html)"
7075 )
7176 args , posargs = parser .parse_known_args (session .posargs )
7277 serve = args .builder == "html" and session .interactive
7378
7479 extra_installs = ["sphinx-autobuild" ] if serve else []
75- session .install ("-r" , "docs/requirements.txt" , * extra_installs )
80+ session .install (* deps , * extra_installs )
7681 session .chdir ("docs" )
7782
7883 if args .builder == "linkcheck" :
@@ -130,7 +135,7 @@ def _bump(session: nox.Session, name: str, repository: str, branch: str, script:
130135 )
131136
132137
133- @nox .session
138+ @nox .session ( default = False )
134139def bump (session : nox .Session ) -> None :
135140 """
136141 Set to a new version, use -- <version>, otherwise will use the latest version.
@@ -146,7 +151,7 @@ def bump(session: nox.Session) -> None:
146151 _bump (session , "CMake" , "kitware/cmake" , "" , "scripts/update_cmake_version.py" , files )
147152
148153
149- @nox .session (name = "bump-openssl" )
154+ @nox .session (name = "bump-openssl" , default = False )
150155def bump_openssl (session : nox .Session ) -> None :
151156 """
152157 Set openssl to a new version, use -- <version>, otherwise will use the latest version.
@@ -162,7 +167,7 @@ def _get_version() -> str:
162167 return next (iter (re .finditer (r'^version = "([\d\.]+)"$' , txt , flags = re .MULTILINE ))).group (1 )
163168
164169
165- @nox .session (venv_backend = "none" )
170+ @nox .session (venv_backend = "none" , default = False )
166171def tag_release (session : nox .Session ) -> None :
167172 """
168173 Print instructions for tagging a release and pushing it to GitHub.
@@ -174,7 +179,7 @@ def tag_release(session: nox.Session) -> None:
174179 print (f"git push origin { current_version } " )
175180
176181
177- @nox .session (venv_backend = "none" )
182+ @nox .session (venv_backend = "none" , default = False )
178183def cmake_version (session : nox .Session ) -> None : # noqa: ARG001
179184 """
180185 Print upstream cmake version.
@@ -184,7 +189,7 @@ def cmake_version(session: nox.Session) -> None: # noqa: ARG001
184189 print ("." .join (current_version .split ("." )[:3 ]))
185190
186191
187- @nox .session (venv_backend = "none" )
192+ @nox .session (venv_backend = "none" , default = False )
188193def openssl_version (session : nox .Session ) -> None : # noqa: ARG001
189194 """
190195 Print upstream OpenSSL version.
0 commit comments