Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
340 lines (299 loc) · 9.23 KB
/
Copy pathpyproject.toml
File metadata and controls
340 lines (299 loc) · 9.23 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
[project]
name = "snapwrap"
description = "Instrument Scientist Scripting Interface into SNAPRed"
dynamic = ["version"]
requires-python = ">=3.10"
license = { text = "MIT" }
keywords = ["neutrons", "example", "python"]
readme = "README.md"
dependencies = [
"scikit-image",
"panel >=1.7.0",
"sqlalchemy >=2.0.0",
"ruamel.yaml",
"lmfit",
"odfpy >=1.4.1",
"h5py",
"scipy",
"python-dateutil",
"packaging",
"pyyaml",
]
# PyPI dependencies
[project.urls]
homepage = "https://github.com/neutrons/python_project_template/" # if no homepage, use repo url
repository = "https://github.com/neutrons/python_project_template/"
# documentation = add_url_to_readthedoc_here
issues = "https://github.com/neutrons/python_project_template/issues"
[project.scripts]
packagename-cli = "packagenamepy.packagename:main"
[project.gui-scripts]
packagenamepy = "packagenamepy.packagename:gui"
####################
### Build config ###
####################
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "versioningit"]
[tool.hatch.version]
source = "versioningit"
[tool.hatch.build.hooks.versioningit-onbuild]
source-file = "src/snapwrap/_version.py"
build-file = "snapwrap/_version.py"
[tool.hatch.build]
artifacts = [
"src/snapwrap/_version.py",
"src/snapwrap/**/*.yml",
"src/snapwrap/**/*.yaml",
"src/snapwrap/**/*.ini",
]
[tool.hatch.build.targets.wheel]
packages = ["src/snapwrap"]
[tool.versioningit.vcs]
method = "git"
default-tag = "0.1.0"
[tool.versioningit.next-version]
method = "minor"
[tool.versioningit.format]
distance = "{next_version}.dev{committer_date:%Y%m%d%H%M%S}"
# Since pixi builds currently require the package version to be set statically in pyproject.toml,
# and we solve that by temporarily changing pyproject.toml during build using the pixi tasks
# sync-version and reset-toml, then we need to ignore uncommitted changes in order for the wheel
# version to be consistent with the package version
dirty = "{version}"
distance-dirty = "{next_version}.dev{committer_date:%Y%m%d%H%M%S}"
[tool.versioningit.write]
file = "src/snapwrap/_version.py"
# [tool.setuptools.packages.find]
# where = ["src"]
# exclude = ["tests*", "scripts*", "docs*", "notebooks*"]
# [tool.setuptools.package-data]
# "*" = [
# "*.yml",
# "*.yaml",
# "*.ini",
# "*.css",
# "*.doctree",
# "*.html",
# "*.inv",
# "*.jpg",
# "*.js",
# "*.map",
# "*.md",
# "*.png",
# "*.po",
# "*.svg",
# "*.ttf",
# "*.txt",
# "*.woff2",
# "*.yml",
# ]
###################
### Pixi config ###
###################
[tool.pixi.workspace]
preview = ["pixi-build"] # Required until the build feature becomes stable
channels = [
"conda-forge",
"mantid/label/main",
"neutrons",
"neutrons/label/rc",
"https://prefix.dev/pixi-build-backends", # Required for pixi build
"oncat",
]
platforms = ["linux-64"] # add additional platforms as needed
[tool.pixi.dependencies]
# TODO: This needs to be cleaned up, I'm not certain which deps are actually used.
snapred = "==2.3.1"
scikit-image = "*"
python = ">=3.10"
panel = ">=1.7.4,<2"
sqlalchemy = ">=2.0.41,<3"
versioningit = "*"
numpy = "*"
pandas = "*"
lmfit = "*"
matplotlib = "*"
jupyterlab = "*"
ipympl = "*"
pre-commit = "*"
libmamba = "*"
libarchive = "*"
anaconda-client = "*"
# conda-build 25+ drops the py-lief <0.15 constraint (CVE-2024-31636, CVE-2025-15504)
conda-build = ">=25"
python-build = "*"
# httpcore 1.0.9+ depends on h11 >=0.16 which fixes CVE-2025-43859
httpcore = ">=1.0.9"
twine = "*"
sphinx = "*"
sphinx_rtd_theme = "*"
myst-parser = "*"
pytest = "*"
pytest-cov = "*"
pytest-xdist = "*"
pip = "*"
odfpy = ">=1.4.1"
h5py = "*"
scipy = "*"
python-dateutil = "*"
packaging = "*"
pyyaml = "*"
# NOTE: this dep SHOULD have been in snapred, but was missed
"ruamel.yaml" = "*"
[tool.pixi.pypi-dependencies]
snapwrap = { path = ".", editable = true }
bm3d-streak-removal = "*"
pytest-playwright = "*"
[tool.pixi.package.host-dependencies]
hatchling = "*"
versioningit = "*"
panel = ">=1.7.4,<2"
sqlalchemy = ">=2.0.41,<3"
[tool.pixi.package.run-dependencies]
python = ">=3.10"
numpy = "*"
QtPy = "*"
pyqt = "*"
pyqtgraph = "*"
scikit-image = "*"
lmfit = "*"
panel = ">=1.7.4,<2"
sqlalchemy = ">=2.0.41,<3"
snapred = "==2.3.1"
odfpy = ">=1.4.1"
h5py = "*"
scipy = "*"
python-dateutil = "*"
packaging = "*"
pyyaml = "*"
pandas = "*"
# NOTE: this dep SHOULD have been in snapred, but was missed
"ruamel.yaml" = "*"
[tool.pixi.package]
name = "snapwrap"
version = "0.0.0" # placeholder, overwritten by sync-version
[tool.pixi.package.build]
backend = { name = "pixi-build-python", version = "*" }
# Environments and Features
[tool.pixi.environments]
default = { features = [
"docs",
"developer",
"package",
"test",
], solve-group = "default" }
jupyter = { features = ["developer", "jupyter"], solve-group = "jupyter" }
[tool.pixi.feature.test.dependencies]
pytest = "*"
pytest-cov = "*"
pytest-repeat = "*"
pytest-xdist = "*"
[tool.pixi.feature.package.dependencies]
anaconda-client = ">=1.13.0,<2"
twine = ">=6.1.0,<7"
versioningit = "*"
hatch = "*"
[tool.pixi.feature.package.pypi-dependencies]
toml-cli = "*"
[tool.pixi.feature.developer.dependencies]
pip = "*"
pip-audit = "*"
pre-commit = "*"
ruff = "*"
versioningit = "*"
[tool.pixi.feature.docs.dependencies]
sphinx = "*"
sphinx_rtd_theme = "*"
myst-parser = "*"
[tool.pixi.feature.jupyter.dependencies]
jupyterlab = "*"
ipympl = "*"
ipywidgets = "*"
[tool.pixi.tasks]
snapwrap = { cmd = "pixi run python -m workbench", description = "Run the workbench in the snapwrap env" }
# Documentation tasks
build-docs = { cmd = "sphinx-build -b html docs docs/_build", description = "Build the documentation" }
# Testing tasks
test = { cmd = "pytest", description = "Run the tests" } # pytest config above takes care of the arguments
# Packaging
pypi-build = { cmd = "hatch build", description = "Build the package for PyPI" }
pypi-publish = { cmd = "twine upload dist/*", description = "Publish the package to PyPI", depends-on = [
"pypi-build",
] }
pypi-publish-test = { cmd = "twine upload --repository testpypi dist/*", description = "Publish the package to TestPyPI", depends-on = [
"pypi-build",
] }
conda-build-command = { cmd = "pixi publish --target-channel ./local-channel", description = "Build the conda package command" }
conda-build = { description = "Build the conda package", depends-on = [
"backup-toml",
"sync-version",
"conda-build-command",
"reset-toml",
] }
conda-publish = { cmd = "anaconda upload *.conda", description = "Publish the .conda package to anaconda.org", depends-on = [
"conda-build",
] }
# Misc
# tornado 6.5.5 fixes CVE-2026-31958 / GHSA-78cv-mqj4-43f7 but is not yet on conda-forge (latest: 6.5.4)
# Remove the --ignore-vuln flags once conda-forge packages tornado >=6.5.5
# multidict 6.9.1 fixes CVE-2026-104874 (reference leak in items-view union/subtraction) but is
# not yet on conda-forge (latest: 6.7.1); it is pulled in by aiohttp. Remove that flag once
# conda-forge packages multidict >=6.9.1.
audit-deps = { cmd = """pip-audit --local -s osv \
--ignore-vuln PYSEC-2026-3447 \
--ignore-vuln PYSEC-2026-2255 \
--ignore-vuln GHSA-78cv-mqj4-43f7 \
--ignore-vuln CVE-2026-31958 \
--ignore-vuln CVE-2026-3219 \
--ignore-vuln PYSEC-2026-165 \
--ignore-vuln PYSEC-2026-2249 \
--ignore-vuln PYSEC-2026-2250 \
--ignore-vuln PYSEC-2026-2251 \
--ignore-vuln PYSEC-2026-2252 \
--ignore-vuln PYSEC-2026-2253 \
--ignore-vuln PYSEC-2026-2254 \
--ignore-vuln PYSEC-2026-2256 \
--ignore-vuln PYSEC-2026-2257 \
--ignore-vuln PYSEC-2026-2874 \
--ignore-vuln PYSEC-2026-3451 \
--ignore-vuln PYSEC-2026-3453 \
--ignore-vuln PYSEC-2026-3454 \
--ignore-vuln PYSEC-2026-3493 \
--ignore-vuln PYSEC-2026-3494 \
--ignore-vuln PYSEC-2026-3495 \
--ignore-vuln PYSEC-2026-3496 \
--ignore-vuln CVE-2026-104874""", description = "Audit the package dependencies for vulnerabilities" }
clean = { cmd = 'rm -rf .pytest_cache .ruff_cache **/*.egg-info **/dist **/__pycache__', description = "Clean up various caches and build artifacts" }
clean-conda = { cmd = "rm -f *.conda", description = "Clean the local .conda build artifacts" }
clean-docs = { cmd = "rm -rf docs/_build", description = "Clean up documentation build artifacts" }
clean-pypi = { cmd = "rm -rf dist", description = "Clean the PyPI build artifacts" }
clean-all = { description = "Clean all artifacts", depends-on = [
"clean",
"clean-conda",
"clean-docs",
"clean-pypi",
] }
sync-version = { cmd = 'version=$(python -m versioningit); toml set tool.pixi.package.version "$version" --toml-path pyproject.toml', description = "Sync pyproject.toml version with Git version" }
backup-toml = { cmd = "cp pyproject.toml pyproject.toml.bak", description = "Backup the pyproject.toml file" }
reset-toml = { cmd = "cp pyproject.toml.bak pyproject.toml; rm pyproject.toml.bak", description = "Reset the pyproject.toml file to the original state" }
##############
### Pytest ###
##############
[tool.pytest.ini_options]
addopts = "-v --cov=snapwrap --cov-report=term-missing"
pythonpath = [
".", "src", "scripts"
]
testpaths = ["tests"]
python_files = ["test*.py"]
norecursedirs = [".git", "tmp*", "_tmp*", "__pycache__", "*dataset*", "*data_set*"]
markers = [
"mymarker: example markers goes here"
]
############
### Ruff ###
############
[tool.ruff]
line-length = 120
select = ["A", "ARG","ASYNC","BLE","C90", "E", "F", "I", "N", "UP032", "W"]