Repository navigation
Expand file tree
/
Copy pathpixi.toml
More file actions
356 lines (290 loc) ยท 15.5 KB
/
Copy pathpixi.toml
File metadata and controls
356 lines (290 loc) ยท 15.5 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
###########
# WORKSPACE
###########
[workspace]
# Supported platforms for the lock file (pixi.lock)
platforms = [
'win-64',
# Set minimum supported version for glibc to be 2.35 to ensure packages
# like `crysfml` that only have wheels for glibc 2.35+
# (manylinux_2_35_x86_64) are used.
#libc = { family = 'glibc', version = '2.35' }
{ platform = 'linux-64', glibc = '2.35' },
# Set minimum supported version for macOS to be 14.0 to ensure packages
# like `scipp` that only have wheels for macOS 14.0+ (macosx_14_0_arm64)
# are used instead of building from source. This is a workaround for
# Pixi, see https://github.com/prefix-dev/pixi/issues/5667
{ platform = 'osx-arm64', macos = '14.0' },
]
# Channels for fetching packages
channels = ['nodefaults', 'conda-forge']
##########
# FEATURES
##########
# Default features:
[activation.env]
PYTHONIOENCODING = 'utf-8'
# Non-default features:
# Set specific Python versions to be used in CI testing.
[feature.py-min.dependencies]
python = '3.12.*'
[feature.py-max.dependencies]
python = '3.14.*'
# Development dependencies for local development and testing with
# editable installations.
[feature.dev.dependencies]
nodejs = '*' # Required for Prettier (non-Python formatting)
jupyterlab = '*' # Jupyter notebooks
ipython = '*' # Interactive Python shell
pixi-kernel = '*' # Pixi Jupyter kernel
ipykernel = '*' # Jupyter kernel base; required for pixi-kernel
gsl = '*' # GNU Scientific Library; required for diffpy.pdffit2
tectonic = '*' # LaTeX engine for PDF report generation
lychee = '*' # Link checker for documentation
[feature.dev.pypi-dependencies]
pip = '*'
#pycrysfml = { version = ">=0.4.0", index = "https://easyscience.github.io/pypi/" }
#cryspy = { git = "https://github.com/ikibalin/cryspy.git", branch = "fix-tof-lorentz-half-angle" }
easydiffraction = { path = '.', editable = true, extras = ['dev'] }
# User-like behavior for testing with pip-installed dependencies instead
# of editable installations.
[feature.user.dependencies]
jupyterlab = '*' # Jupyter notebooks
ipython = '*' # Interactive Python shell
pixi-kernel = '*' # Pixi Jupyter kernel
[feature.user.pypi-dependencies]
pip = '*'
easydiffraction = '*'
##############
# ENVIRONMENTS
##############
[environments]
# The `default` feature is always included in all environments.
# Additional features can be specified per environment.
# Specific environments for CI testing with different Python versions.
py-312-env = { features = ['py-min', 'dev'] }
py-314-env = { features = ['py-max', 'dev'] }
# The `default` environment is developer-oriented for local development
# and testing with editable installation of the current package.
default = { features = ['py-max', 'dev'] }
# The `user` environment allows testing with pip-installed dependencies
# instead of editable installation of the current package.
user = { features = ['py-max', 'user'] }
#######
# TASKS
#######
[tasks]
##################
# ๐งช Testing Tasks
##################
unit-tests = 'python -m pytest tests/unit/ --color=yes -v'
functional-tests = 'python -m pytest tests/functional/ --color=yes -v'
integration-tests = 'python -m pytest tests/integration/ --color=yes -n auto -v'
# Run nightly-tier tests across the suite (benchmarks have their own task
# because pytest-benchmark does not run under xdist).
nightly-tests = 'python -m pytest tests/ -m nightly --ignore=tests/benchmarks --color=yes -n auto -v'
# Performance benchmarks, per experiment type; writes benchmark.json for
# the nightly CI artifact. Informational (no regression gate yet).
benchmarks = 'python -m pytest tests/benchmarks/ --benchmark-only --benchmark-json=benchmark.json --color=yes -v'
# Remove previously saved tutorial output projects (the slug-named
# projects/* directories) so the tutorial-output checks cannot pass against a
# stale artifact from an earlier run. Downloaded project archives
# (projects/proj-*) are preserved so they need not be re-downloaded.
clean-tutorial-projects = { cmd = 'python tools/clean_tutorial_projects.py', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
script-tests = { cmd = 'python -m pytest tools/test_scripts.py --color=yes -n auto -v', depends-on = [
'clean-tutorial-projects',
], env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
notebook-tests = { cmd = 'python -m pytest --nbmake docs/docs/tutorials/ docs/docs/verification/ --nbmake-timeout=1200 --color=yes -n auto -v', depends-on = [
'clean-tutorial-projects',
], env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
# Parse the analysis.edi of every saved tutorial project and assert its
# refined fit results against tests/tutorials/baseline.json. Run only after
# the tutorials have been executed (script-tests or notebook-tests), so the
# saved projects exist under tmp/tutorials/projects/.
tutorial-output-tests = { cmd = 'python -m pytest tests/tutorials/ --color=yes -v', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
# Run the tutorials and then verify their saved outputs in a single step.
script-tests-checked = { cmd = 'python -m pytest tests/tutorials/ --color=yes -v', depends-on = [
'script-tests',
], env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
notebook-tests-checked = { cmd = 'python -m pytest tests/tutorials/ --color=yes -v', depends-on = [
'notebook-tests',
], env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
test = { depends-on = ['unit-tests', 'functional-tests'] }
# Full local gate before opening a PR: every static check, unit coverage,
# all tests, tutorial execution + output verification (as scripts AND
# notebooks), and a strict documentation build (which validates the built
# site's nav/links). Steps run sequentially because the tutorial tasks
# share tmp/tutorials/projects/. Slow but comprehensive โ run `pixi run
# fix` first to auto-format.
all = 'pixi run check && pixi run unit-tests-coverage && pixi run functional-tests && pixi run integration-tests && pixi run script-tests-checked && pixi run notebook-tests-checked && pixi run docs-build-local'
###########
# โ๏ธ Checks
###########
pyproject-check = 'python -m validate_pyproject pyproject.toml'
docstring-lint-check = 'pydoclint --quiet src/'
notebook-lint-check = 'nbqa ruff docs/docs/tutorials/ docs/docs/verification/'
py-lint-check = 'ruff check src/ tests/ docs/docs/tutorials/ docs/docs/verification/'
py-format-check = 'ruff format --check src/ tests/ docs/docs/tutorials/ docs/docs/verification/'
nonpy-format-check = 'npx prettier --list-different --config=prettierrc.toml --ignore-unknown .'
nonpy-format-check-modified = 'python tools/nonpy_prettier_modified.py'
test-structure-check = 'python tools/test_structure_check.py'
# Spelling over docs and source (config in [tool.codespell]).
spell-check = 'codespell docs src tools README.md CONTRIBUTING.md'
# Local/relative documentation link integrity (offline; external URL
# checking is deferred, see issue 114). Config in lychee.toml.
link-check = 'lychee --config lychee.toml docs/docs README.md CONTRIBUTING.md'
check = 'pre-commit run --hook-stage manual --all-files'
##########
# ๐ ๏ธ Fixes
##########
docstring-transform = 'pixi run docstripy src/ -s=numpy -w'
docstring-format-fix = 'format-docstring src/'
notebook-lint-fix = 'nbqa ruff --fix docs/docs/tutorials/ docs/docs/verification/'
py-lint-fix = 'ruff check --fix src/ tests/ docs/docs/tutorials/ docs/docs/verification/'
py-lint-fix-unsafe = 'ruff check --fix --unsafe-fixes src/ tests/ docs/docs/tutorials/ docs/docs/verification/'
py-format-fix = 'ruff format src/ tests/ docs/docs/tutorials/ docs/docs/verification/'
nonpy-format-fix = 'npx prettier --write --list-different --config=prettierrc.toml --ignore-unknown .'
nonpy-format-fix-modified = 'python tools/nonpy_prettier_modified.py --write'
update-package-diagrams = 'python tools/generate_package_docs.py'
success-message = 'echo "โ
All auto-formatting steps completed successfully!"'
fix = { depends-on = [
#'param-docstring-fix', # ED only
'docstring-format-fix',
'py-format-fix',
'py-lint-fix',
'nonpy-format-fix',
'notebook-lint-fix',
'update-package-diagrams',
'success-message',
] }
####################
# ๐งฎ Code Complexity
####################
complexity-check = 'radon cc -s src/'
complexity-check-json = 'radon cc -s -j src/'
maintainability-check = 'radon mi src/'
maintainability-check-json = 'radon mi -j src/'
raw-metrics = 'radon raw -s src/'
raw-metrics-json = 'radon raw -s -j src/'
#############
# ๐ Coverage
#############
unit-tests-coverage = 'pixi run unit-tests --cov=src/easydiffraction --cov-report=term-missing'
functional-tests-coverage = 'pixi run functional-tests --cov=src/easydiffraction --cov-report=term-missing'
integration-tests-coverage = 'pixi run integration-tests --cov=src/easydiffraction --cov-report=term-missing'
docstring-coverage = 'interrogate -c pyproject.toml src/easydiffraction'
cov = { depends-on = ['docstring-coverage', 'unit-tests-coverage'] }
########################
# ๐ Notebook Management
########################
python = { cmd = 'python', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
tutorial = { cmd = 'python', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
tutorial-benchmarks = { cmd = 'python tools/benchmark_tutorials.py', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
jupyter = { cmd = 'jupyter', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials' } }
notebook-convert = 'jupytext docs/docs/tutorials/*.py docs/docs/verification/*.py --from py:percent --to ipynb'
notebook-strip = 'nbstripout docs/docs/tutorials/*.ipynb docs/docs/verification/*.ipynb'
notebook-tweak = 'python tools/tweak_notebooks.py docs/docs/tutorials/ docs/docs/verification/'
notebook-exec = { cmd = 'python -m pytest --nbmake docs/docs/tutorials/ docs/docs/verification/ --overwrite --color=yes -n auto -v', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials', EASYDIFFRACTION_FIGURE_EMBED_MODE = 'shared' } }
notebook-exec-ci = { cmd = 'python -m pytest --nbmake docs/docs/tutorials/ docs/docs/verification/ --nbmake-timeout=1200 --overwrite --color=yes -n auto -v', env = { EASYDIFFRACTION_ARTIFACT_ROOT = '.', EASYDIFFRACTION_FIGURE_EMBED_MODE = 'shared' } }
# Execute and overwrite outputs for the verification notebooks only (the
# verification-page subset of notebook-exec); nbmake runs every page, and
# a known-bad page is gated by its in-notebook known_discrepancy flag.
verification-exec = { cmd = 'python -m pytest --nbmake docs/docs/verification/ --overwrite --color=yes -n auto -v', env = { EASYDIFFRACTION_ARTIFACT_ROOT = 'tmp/tutorials', EASYDIFFRACTION_FIGURE_EMBED_MODE = 'shared' } }
notebook-prepare = { depends-on = [
'notebook-convert',
'notebook-tweak',
'notebook-strip',
] }
########################
# ๐ Documentation Tasks
########################
docs-vars = "JUPYTER_PLATFORM_DIRS=1 PYTHONWARNINGS='ignore::RuntimeWarning'"
docs-pre = 'pixi run docs-vars python -m mkdocs'
# Copy the canonical Three.js snapshot into the (git-ignored) docs
# assets before any build/serve so MkDocs can serve it.
docs-sync-vendored-js = 'python tools/sync_docs_vendored_js.py'
docs-serve = { cmd = 'pixi run docs-pre serve -f docs/mkdocs.yml', depends-on = [
'docs-sync-vendored-js',
] }
docs-serve-dirty = 'pixi run docs-serve --dirty'
# Strict build (fails on broken nav / internal references); used for the
# deploy and the CI docs check. Tutorials are not executed (mkdocs-jupyter
# execute: false). docs-serve is intentionally left non-strict.
docs-build = { cmd = 'pixi run docs-pre build --strict -f docs/mkdocs.yml', depends-on = [
'docs-sync-vendored-js',
] }
# Inherits --strict; --no-directory-urls makes the built site browsable
# from disk (used by `all` so you can inspect it after verifying).
docs-build-local = 'pixi run docs-build --no-directory-urls'
docs-inventory-check = 'python -c "from pathlib import Path; p = Path(\"docs/site/objects.inv\"); raise SystemExit(0 if p.is_file() and p.stat().st_size > 0 else \"missing or empty docs/site/objects.inv\")"'
docs-deploy-pre = 'mike deploy -F docs/mkdocs.yml --push --branch gh-pages --update-aliases --alias-type copy'
docs-set-default-pre = 'mike set-default -F docs/mkdocs.yml --push --branch gh-pages'
docs-update-assets = 'python tools/update_docs_assets.py'
# Vendored JavaScript runtimes (Plotly cartesian bundle + Three.js).
# vendor-update-js re-fetches the pinned versions; vendor-check-js is a
# no-network drift guard for CI.
vendor-update-js = 'python tools/bump_vendored_js.py'
vendor-check-js = 'python tools/bump_vendored_js.py --check'
##############################
# ๐ฆ Template Management Tasks
##############################
copier-copy = 'copier copy gh:easyscience/templates . --data-file ../diffraction/.copier-answers.yml --data template_type=lib'
copier-recopy = 'copier recopy --data-file ../diffraction/.copier-answers.yml --data template_type=lib'
copier-update = 'copier update --data-file ../diffraction/.copier-answers.yml --data template_type=lib'
#####################
# ๐ช Pre-commit Hooks
#####################
pre-commit-clean = 'pre-commit clean'
pre-commit-install = 'pre-commit install --hook-type pre-commit --hook-type pre-push --overwrite'
pre-commit-uninstall = 'pre-commit uninstall --hook-type pre-commit --hook-type pre-push'
pre-commit-setup = { depends-on = [
'pre-commit-clean',
'pre-commit-uninstall',
'pre-commit-install',
] }
#################
# ๐๏ธ GitHub Tasks
#################
repo-wiki = 'gh api -X PATCH repos/easyscience/diffraction-lib -f has_wiki=false'
repo-discussions = 'gh api -X PATCH repos/easyscience/diffraction-lib -f has_discussions=true'
repo-description = "gh api -X PATCH repos/easyscience/diffraction-lib -f description='Diffraction data analysis'"
repo-homepage = "gh api -X PATCH repos/easyscience/diffraction-lib -f homepage='https://easyscience.github.io/diffraction-lib'"
repo-config = { depends-on = [
'repo-wiki',
'repo-discussions',
'repo-description',
'repo-homepage',
] }
master-protection = 'gh api -X POST repos/easyscience/diffraction-lib/rulesets --input .github/configs/rulesets-master.json'
develop-protection = 'gh api -X POST repos/easyscience/diffraction-lib/rulesets --input .github/configs/rulesets-develop.json'
gh-pages-protection = 'gh api -X POST repos/easyscience/diffraction-lib/rulesets --input .github/configs/rulesets-gh-pages.json'
branch-protection = { depends-on = [
'master-protection',
'develop-protection',
'gh-pages-protection',
] }
pages-deployment = 'gh api -X POST repos/easyscience/diffraction-lib/pages --input .github/configs/pages-deployment.json'
github-labels = 'python tools/update_github_labels.py'
#########################
# โ๏ธ SPDX License Headers
#########################
license-remove = 'python tools/license_headers.py remove src/ tests/ --exclude-from-pyproject-toml tool.ruff.exclude'
license-add = 'python tools/license_headers.py add src/ tests/ --exclude-from-pyproject-toml tool.ruff.exclude'
license-check = 'python tools/license_headers.py check src/ tests/ --exclude-from-pyproject-toml tool.ruff.exclude'
####################################
# ๐ Other Development & Build Tasks
####################################
default-build = 'python -m build'
dist-build = 'python -m build --wheel --outdir dist'
npm-config = 'npm config set registry https://registry.npmjs.org/'
prettier-install = 'npm install --no-save --no-audit --no-fund prettier prettier-plugin-toml'
clean-pycache = "find . -type d -name '__pycache__' -prune -exec rm -rf '{}' +"
post-install = { depends-on = [
'npm-config',
'prettier-install',
#'pre-commit-setup',
] }
##########################
# ๐ Main Package Shortcut
##########################
easydiffraction = 'python -m easydiffraction'