1
+ # /// script
2
+ # dependencies = ["nox>=2025.2.9"]
3
+ # ///
4
+
1
5
import argparse
2
6
import re
3
7
from pathlib import Path
4
8
5
9
import nox
6
10
7
- nox .needs_version = ">=2024.3.2 "
11
+ nox .needs_version = ">=2025.2.9 "
8
12
nox .options .default_venv_backend = "uv|virtualenv"
9
- nox .options .sessions = ["lint" , "build" , "tests" ]
10
13
11
14
BUILD_ENV = {
12
15
"MACOSX_DEPLOYMENT_TARGET" : "10.10" ,
13
16
"ARCHFLAGS" : "-arch x86_64 -arch arm64" ,
14
17
}
15
18
16
- built = ""
19
+ wheel = ""
17
20
18
21
19
22
@nox .session
20
23
def build (session : nox .Session ) -> str :
21
24
"""
22
- Make an SDist and a wheel. Only runs once.
25
+ Make an SDist and a wheel.
23
26
"""
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 } "
39
42
40
43
41
44
@nox .session
@@ -47,32 +50,34 @@ def lint(session: nox.Session) -> str:
47
50
session .run ("pre-commit" , "run" , "-a" )
48
51
49
52
50
- @nox .session
53
+ @nox .session ( requires = [ "build" ])
51
54
def tests (session : nox .Session ) -> str :
52
55
"""
53
56
Run the tests.
54
57
"""
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 )
57
61
session .run ("pytest" , * session .posargs )
58
62
59
63
60
- @nox .session (reuse_venv = True )
64
+ @nox .session (reuse_venv = True , default = False )
61
65
def docs (session : nox .Session ) -> None :
62
66
"""
63
67
Build the docs. Pass "--non-interactive" to avoid serve. Pass "-- -b linkcheck" to check links.
64
68
"""
69
+ pyproject = nox .project .load_toml ("pyproject.toml" )
70
+ deps = nox .project .dependency_groups (pyproject , "docs" )
65
71
66
72
parser = argparse .ArgumentParser ()
67
- parser .add_argument ("--serve" , action = "store_true" , help = "Serve after building" )
68
73
parser .add_argument (
69
74
"-b" , dest = "builder" , default = "html" , help = "Build target (default: html)"
70
75
)
71
76
args , posargs = parser .parse_known_args (session .posargs )
72
77
serve = args .builder == "html" and session .interactive
73
78
74
79
extra_installs = ["sphinx-autobuild" ] if serve else []
75
- session .install ("-r" , "docs/requirements.txt" , * extra_installs )
80
+ session .install (* deps , * extra_installs )
76
81
session .chdir ("docs" )
77
82
78
83
if args .builder == "linkcheck" :
@@ -130,7 +135,7 @@ def _bump(session: nox.Session, name: str, repository: str, branch: str, script:
130
135
)
131
136
132
137
133
- @nox .session
138
+ @nox .session ( default = False )
134
139
def bump (session : nox .Session ) -> None :
135
140
"""
136
141
Set to a new version, use -- <version>, otherwise will use the latest version.
@@ -146,7 +151,7 @@ def bump(session: nox.Session) -> None:
146
151
_bump (session , "CMake" , "kitware/cmake" , "" , "scripts/update_cmake_version.py" , files )
147
152
148
153
149
- @nox .session (name = "bump-openssl" )
154
+ @nox .session (name = "bump-openssl" , default = False )
150
155
def bump_openssl (session : nox .Session ) -> None :
151
156
"""
152
157
Set openssl to a new version, use -- <version>, otherwise will use the latest version.
@@ -162,7 +167,7 @@ def _get_version() -> str:
162
167
return next (iter (re .finditer (r'^version = "([\d\.]+)"$' , txt , flags = re .MULTILINE ))).group (1 )
163
168
164
169
165
- @nox .session (venv_backend = "none" )
170
+ @nox .session (venv_backend = "none" , default = False )
166
171
def tag_release (session : nox .Session ) -> None :
167
172
"""
168
173
Print instructions for tagging a release and pushing it to GitHub.
@@ -174,7 +179,7 @@ def tag_release(session: nox.Session) -> None:
174
179
print (f"git push origin { current_version } " )
175
180
176
181
177
- @nox .session (venv_backend = "none" )
182
+ @nox .session (venv_backend = "none" , default = False )
178
183
def cmake_version (session : nox .Session ) -> None : # noqa: ARG001
179
184
"""
180
185
Print upstream cmake version.
@@ -184,7 +189,7 @@ def cmake_version(session: nox.Session) -> None: # noqa: ARG001
184
189
print ("." .join (current_version .split ("." )[:3 ]))
185
190
186
191
187
- @nox .session (venv_backend = "none" )
192
+ @nox .session (venv_backend = "none" , default = False )
188
193
def openssl_version (session : nox .Session ) -> None : # noqa: ARG001
189
194
"""
190
195
Print upstream OpenSSL version.
0 commit comments