Repository navigation
Expand file tree
/
Copy pathtox.toml
More file actions
203 lines (194 loc) · 5.64 KB
/
Copy pathtox.toml
File metadata and controls
203 lines (194 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
requires = [ "tox>=4.64.7", "tox-uv>=1.36.1" ]
env_list = [ "3.15", "3.14", "3.13", "3.12", "3.11", "3.14t", "3.15t", "docs", "fix", "pkg_meta", "type" ]
labels.lint = [ "fix", "pkg_meta", "type" ]
labels.test = [ "3.15", "3.14", "3.13", "3.12", "3.11", "3.14t", "3.15t" ]
skip_missing_interpreters = true
[env_run_base]
description = "run the tests with pytest under {env_name}"
default_base_python = [ "3.15" ]
package = "wheel"
wheel_build_env = ".pkg"
dependency_groups = [ "test" ]
pass_env = [ "PYTEST_*" ]
set_env.COVERAGE_FILE = { replace = "env", name = "COVERAGE_FILE", default = "{env_tmp_dir}{/}.coverage" }
commands = [
[
"pytest",
{ replace = "posargs", default = [
"--no-cov-on-fail",
"--cov",
"python_sbom",
"--cov",
"{tox_root}{/}tests",
"--cov-config",
"{tox_root}{/}pyproject.toml",
"--cov-context",
"test",
"--cov-report",
"term-missing:skip-covered",
"--cov-report",
"html:{env_tmp_dir}{/}htmlcov",
"tests",
# each example builds with a backend of its own, which only its example environment installs
"--ignore",
"{tox_root}{/}tests{/}examples",
], extend = true },
],
]
[env_pkg_base]
default_base_python = [ "3.15" ]
[env.docs]
description = "Build documentation"
dependency_groups = [ "docs" ]
commands = [
[
"python",
"-c",
# RE2 lacks Python 3.15 wheels: https://github.com/google/re2/issues/647
"""\
import glob; import pathlib; import subprocess; subprocess.check_call(['uv', 'tool', 'run', '--python', '3.14', \
'--from', 'proselint>=0.16', 'proselint', 'check', *(path for path in glob.glob('docs/**/*.rst', recursive=True) if \
pathlib.Path(path).name not in {'changelog.rst', 'index.rst'} and 'changelog.d' not in pathlib.Path(path).parts)])\
""",
],
[
"sphinx-build",
"-d",
"{env_tmp_dir}/doctree",
"docs",
"{env:READTHEDOCS_OUTPUT:{env_tmp_dir}{/}docs_out}/html",
"--color",
"-b",
"html",
"-W",
"--keep-going",
{ replace = "posargs", extend = true },
],
[
"python",
"-c",
"""\
import pathlib; print('documentation available under ' + \
(pathlib.Path(r'{env:READTHEDOCS_OUTPUT:{env_tmp_dir}{/}docs_out}/html') / 'index.html').as_uri())\
""",
],
]
[env.fix]
description = "format the code base to adhere to our styles, and complain about what we cannot do automatically"
skip_install = true
dependency_groups = [ "lint" ]
pass_env = [
{ replace = "ref", of = [
"env_run_base",
"pass_env",
], extend = true },
"DISABLE_PRE_COMMIT_UV_PATCH",
"PROGRAMDATA",
]
commands = [ [ "pre-commit", "run", "--all-files", "--show-diff-on-failure", { replace = "posargs", extend = true } ] ]
[env.pkg_meta]
description = "check that the long description is valid"
skip_install = true
dependency_groups = [ "pkg_meta" ]
commands = [
[
"uv",
"build",
"--sdist",
"--wheel",
"--out-dir",
"{env_tmp_dir}",
".",
],
[
"twine",
"check",
"--strict",
"{env_tmp_dir}{/}*",
],
[
"check-wheel-contents",
"--no-config",
# the CycloneDX schemas' Apache-2.0 LICENSE ships beside them and, as a license file, again under .dist-info/licenses
"--ignore",
"W002",
"{env_tmp_dir}",
],
[
"python",
"-c",
# the project's own wheel carries the SBOM its hook writes, which lists that hook script among the build tools
"""\
import glob, json, zipfile; (wheel,) = glob.glob(r'{env_tmp_dir}{/}*.whl'); archive = zipfile.ZipFile(wheel); \
(sbom,) = (name for name in archive.namelist() if '/sboms/' in name); tools = \
json.loads(archive.read(sbom))['metadata']['tools']['components']; assert any(tool['name'] == 'hatch_build.py' for \
tool in tools), f'hatch_build.py missing from {sbom}'\
""",
],
[
"python",
"-c",
# the built wheel validates its own SBOM, so a schema file or validator dependency left out of it fails here
"""\
import glob, pathlib, subprocess, sys; (wheel,) = glob.glob(r'{env_tmp_dir}{/}*.whl'); subprocess.check_call(['uv', \
'pip', 'install', '--python', sys.executable, f'python-sbom[validate] @ {pathlib.Path(wheel).as_uri()}'])\
""",
],
[
"python-sbom",
"validate",
"{env_tmp_dir}",
],
]
[env.type]
description = "run type check on code base"
dependency_groups = [ "type" ]
commands = [ [ "ty", "check", "--output-format", "concise", "--error-on-warning", "--python-platform", "all", "." ] ]
[env.bench]
description = "time python-sbom's hot paths with pyperf (not run in CI); `prepare` the fixtures first"
dependency_groups = [ "bench" ]
extras = [ "hatch", "validate" ]
set_env.PYTHONPATH = "{tox_root}"
commands = [ [ "python", "-m", "bench", { replace = "posargs", extend = true } ] ]
[env.dev]
description = "dev environment with all deps at {envdir}"
package = "editable"
dependency_groups = [ "dev" ]
commands = [
[ "uv", "pip", "tree" ],
[ "python", "-c", "import sys; print(sys.executable)" ],
]
[env_base.example]
factors = [
{ backend = [
"cibuildwheel",
"delocate",
"flit_core",
"hatchling",
"maturin",
"meson_python",
"pdm_backend",
"poetry_core",
"scikit_build_core",
"setuptools",
"uv_build",
"zipapp",
] },
]
description = "build the {factor:backend} example of the docs and check its documented session"
dependency_groups = [ "{factor:backend}" ]
extras = [ "validate" ]
commands = [
[
"pytest",
"--cov",
"{tox_root}{/}tests{/}examples",
"--cov-config",
"{tox_root}{/}pyproject.toml",
"--cov-report",
"term-missing:skip-covered",
"{tox_root}{/}tests{/}examples{/}{factor:backend}",
{ replace = "posargs", extend = true },
],
]
labels = [ "examples" ]