-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpyproject.toml
More file actions
400 lines (350 loc) · 16.8 KB
/
pyproject.toml
File metadata and controls
400 lines (350 loc) · 16.8 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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
[project]
name = "SNAPRed"
description = "A desktop application for Lifecycle Managment of data collected from the SNAP instrument."
dynamic = ["version"]
requires-python = ">=3.10"
dependencies = []
readme = "README.md"
license = { text = "GPL-3.0-only" }
[project.urls]
homepage = "https://github.com/neutrons/SNAPRed" # if no homepage, use repo url
repository = "https://github.com/neutrons/SNAPRed"
# documentation = add_url_to_readthedoc_here
issues = "https://github.com/neutrons/SNAPRed/issues"
[project.scripts]
snapred = "snapred.__main__:main"
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "versioningit"]
[tool.hatch.version]
source = "versioningit"
[tool.hatch.build.hooks.versioningit-onbuild]
source-file = "src/snapred/_version.py"
build-file = "snapred/_version.py"
[tool.hatch.build]
artifacts = [
"src/snapred/_version.py",
"src/snapred/**/*.yml",
"src/snapred/**/*.yaml",
"src/snapred/**/*.ini",
]
[tool.setuptools.packages.find]
where = ["src"]
exclude = ["tests*"]
[tool.setuptools.package-data]
"*" = ["*.ui", "*.txt","*.yml","*.yaml","*.qss"]
[tool.versioningit.vcs]
method = "git"
default-tag = "0.0.1"
[tool.versioningit.next-version]
method = "minor"
[tool.versioningit.format]
distance = "{next_version}.dev{distance}"
# 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{distance}"
[tool.versioningit.write]
file = "src/snapred/_version.py"
[tool.pytest.ini_options]
pythonpath = [
"src"
]
markers = [
"integration: mark a test as an integration test",
"mount_snap: mark a test as using /SNS/SNAP/ data mount",
"golden_data(*, path=None, short_name=None, date=None): mark golden data to use with a test",
"datarepo: mark a test as using snapred-data repo",
"ui: mark a test as a UI test",
]
# The following will be overridden by the commandline option "-m integration"
addopts = "-m 'not (integration or datarepo)'"
[tool.ruff]
line-length = 120
# https://beta.ruff.rs/docs/rules/
select = ["A", "ARG", "BLE", "E", "F", "I", "PT", "TID251"]
ignore = ["F403", "F405", # wild imports and unknown names
]
exclude = ["docs"]
extend-exclude = ["conftest.py"]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"mantid.simpleapi".msg = "In the SNAPRed backend, any calls to 'mantid.simpleapi' algorithms should be routed through 'MantidSnapper'."
[tool.ruff.lint.per-file-ignores]
# exceptions: ban import of `mantid.simpleapi` ("TID251"):
"tests/*" = ["TID251"]
"src/snapred/backend/recipe/algorithm*" = ["TID251"]
"src/snapred/backend/recipe/GenericRecipe.py" = ["TID251"]
"src/snapred/resources/ultralite*" = ["TID251"]
[tool.mypy]
plugins = [
"pydantic.mypy"
]
ignore_missing_imports = true # gets around mantid imports
exclude = [
"tests/",
"src/snapred/backend/",
"src/snapred/meta/",
"src/snapred/ui/"
]
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
[tool.coverage.run]
source = ["src/snapred"]
omit = [
"*/tests/*",
"conda.recipe/*",
"docs/*",
"src/snapred/__init__.py",
"src/snapred/ui/*",
"src/snapred/backend/dao/*",
"src/snapred/_version.py",
]
[tool.coverage.report]
fail_under = 1
exclude_lines = [
'if __name__ == "__main__":'
]
# ---------------- #
# Pixi Config #
# ---------------- #
[tool.pixi.workspace]
preview = ["pixi-build"]
channels = [
"conda-forge",
"mantid/label/nightly", # Nightly builds for development
"mantid-ornl/label/nightly", # ORNL-specific nightly builds
"neutrons/label/nightly", # Neutron facility nightly builds
"mantid/label/main", # Primary source for stable Mantid releases
"mantid-ornl/label/main", # ORNL-specific stable releases
"neutrons/label/main", # Neutron facility stable releases
"mantid-ornl/label/rc", # Fallback to RC if stable not available
"neutrons/label/rc", # Fallback to RC if stable not available
"https://prefix.dev/pixi-build-backends", # Required for pixi build
]
platforms = ["linux-64"] # add additional platforms as needed
[tool.pixi.environments]
default = {features = ["test", "package", "docs", "developer", "dev"], solve-group = "default"}
docs = {features = ["docs"], solve-group = "docs"}
# Environment for local Mantid development - excludes conda Mantid packages
local-mantid = {features = ["local-mantid"], solve-group = "local-mantid"}
# Production environment with stable Mantid versions
prod = {features = ["test", "package", "docs", "prod"], solve-group = "prod"}
# Development environment with nightly Mantid builds
dev = {features = ["test", "package", "docs", "dev"], solve-group = "dev"}
# QA environment with RC or prod packages
qa = {features = ["test", "package", "docs", "qa"], solve-group = "qa"}
[tool.pixi.pypi-dependencies]
snapred = { path = ".", editable = true }
[tool.pixi.dependencies]
python = ">=3.10"
pip = ">=25.3"
pydantic = ">=2.7.3,<3"
# Mantid packages moved to feature-specific dependencies with channel constraints
"ruamel.yaml" = "*"
qtpy = "*"
muparser = "=2.3.4"
pycifrw = "*"
pyqtwebengine = "*"
git-lfs = "*"
pre-commit = ">=4.3.0,<5"
virtualenv = "<21" #mismatched pins causes hatch to fail
[tool.pixi.package.host-dependencies]
python = ">=3.10"
hatchling = "*"
virtualenv = "<21" #mismatched pins causes hatch to fail
versioningit = "*"
setuptools = "*" # ci fails in binstar because `No module named 'pkg_resources'`
[tool.pixi.package.run-dependencies]
mantidworkbench = ">=6.15.0,<6.16"
pydantic = ">=2.7.3,<3"
"ruamel.yaml" = "*"
[tool.pixi.package]
name = "snapred"
version = "0.0.0" # placeholder, overwritten by sync-version
[tool.pixi.package.build]
backend = { name = "pixi-build-python", version = "*" }
# --------------- #
# Pixi Tasks #
# --------------- #
[tool.pixi.tasks]
# PyPi packaging tasks
build-pypi = { cmd = "hatch build", description = "Build the package for PyPI" }
publish-pypi = { cmd = "twine upload dist/*", description = "Publish the package to PyPI", depends-on = ["build-pypi"] }
publish-pypi-test = { cmd = "twine upload --repository testpypi dist/*", description = "Publish the package to TestPyPI", depends-on = ["build-pypi"] }
clean-pypi = { cmd = "rm -rf dist", description = "Clean the PyPI build artifacts" }
test-built-package = { cmd = "pip install dist/*.whl && python -c 'import snapred; print(\"✅ Built package installs and imports successfully\")'", description = "Test that the built package can be installed and imported" }
build-configure-app = { cmd = "python -m snapred --configure", description = "Configure the application for building" }
build-conda-command = { cmd = "pixi build", description = "Build the conda package command" }
build-conda = { description = "Build the conda package", depends-on = ["backup-toml", "sync-version", "build-configure-app", "build-conda-command", "reset-toml"] }
publish-conda = { cmd = "anaconda upload --user neutrons *.conda", description = "Publish the .conda package to the neutrons channel (main label)", depends-on = ["build-conda"] }
clean-conda = { cmd = "rm -f *.conda", description = "Clean the local .conda build artifacts" }
# Documentation tasks
build-docs = { cmd = "sphinx-build -b html docs/source docs/_build", description = "Build the documentation" }
clean-docs = { cmd = "rm -rf docs/_build", description = "Clean the documentation build artifacts" }
docs-serve = { cmd = "python -m http.server 8000 -d docs/_build", description = "Serve documentation locally on port 8000" }
docs-autobuild = { cmd = "sphinx-autobuild docs/source docs/_build --host 0.0.0.0 --port 8000", description = "Auto-rebuild and serve docs on changes" }
# Testing tasks
test = { cmd = "pytest --cov=src/snapred --cov-report=xml --cov-report=term", description = "Run the tests with coverage" }
test-integration = { cmd = "env=integration_test pytest -m integration --cov=src/snapred --cov-report=xml --cov-report=term", description = "Run integration tests with coverage" }
test-all = { cmd = "pytest -m 'not datarepo' --cov=src/snapred --cov-report=xml --cov-report=term", description = "Run all tests except datarepo tests" }
# MISC
clean-all = { description = "Clean all build artifacts", depends-on = ["clean-pypi", "clean-docs", "clean-conda"] }
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" }
# Application tasks
snapred = { cmd = "python -m snapred", description = "Start the SNAPRed application" }
# Channel-specific dependencies verification
verify-channel-dependencies = { cmd = "echo '=== SOLUTION 1: Channel-Specific Dependencies Implementation ===' && echo '' && echo '✅ Implementation Status:' && echo ' • Dev feature: mantid packages from mantid/label/nightly' && echo ' • QA feature: mantid packages from mantid-ornl/label/rc' && echo ' • Prod feature: mantid packages from mantid-ornl' && echo '' && echo '📚 Documentation: https://pixi.sh/latest/advanced/channel_logic/#channel-specific-dependencies' && echo '' && echo '⚡ Next step: Run \"pixi update\" to apply changes'", description = "Show channel-specific dependencies implementation status" }
test-mantid-import = { cmd = "python -c \"import mantid, os, sys; print(f'Environment: {os.path.basename(sys.prefix)}'); print(f'Mantid version: {mantid.__version__}'); print(f'Mantid location: {mantid.__file__}')\"", description = "Test Mantid import and show version info" }
# ------------------------------- #
# Pixi Feature Dependencies #
# ------------------------------- #
[tool.pixi.feature.test.dependencies]
pytest = "*"
pytest-qt = "*"
pytest-cov = "*"
"ruamel.yaml" = "*"
pyyaml = "*"
[tool.pixi.feature.package.dependencies]
boa = "*"
anaconda-client = ">=1.14"
conda-build = "*"
check-wheel-contents = ">=0.6.0"
twine = "*"
versioningit = "*"
hatch = "*"
setuptools = "*"
toml = "*"
"ruamel.yaml" = "*"
[tool.pixi.feature.package.pypi-dependencies]
toml-cli = "*"
[tool.pixi.feature.developer.dependencies]
pre-commit = "*"
ruff = "*"
python-build = "*"
[tool.pixi.feature.docs.dependencies]
sphinx = "<9" # sphinx 9 seems to break the doc build for whatever reason
sphinx_rtd_theme = "*"
sphinxcontrib-mermaid = "*"
types-pyyaml = "*"
erdantic = "*"
versioningit = "*"
"ruamel.yaml" = "*"
# ------------------------------- #
# Development Environment Feature #
# ------------------------------- #
[tool.pixi.feature.dev.dependencies]
python = ">=3.10"
pip = ">=25.3"
pydantic = ">=2.7.3,<3"
# Channel-specific dependencies: Dev uses nightly Mantid builds
mantidworkbench = { version = ">=6.15.0,<6.16", channel = "mantid/label/nightly" }
mantid = { version = ">=6.15.0,<6.16", channel = "mantid/label/nightly" }
mantidqt = { version = ">=6.15.0,<6.16", channel = "mantid/label/nightly" }
qtpy = "*"
muparser = "=2.3.4"
pycifrw = "*"
pyqtwebengine = "*"
git-lfs = "*"
# ------------------------------- #
# QA Environment Feature #
# ------------------------------- #
[tool.pixi.feature.qa.dependencies]
python = ">=3.10"
pip = ">=25.3"
pydantic = ">=2.7.3,<3"
# Channel-specific dependencies: QA uses RC Mantid builds
mantidworkbench = { version = ">=6.15.0,<6.16", channel = "mantid-ornl/label/rc" }
mantid = { version = ">=6.15.0,<6.16", channel = "mantid-ornl/label/rc" }
mantidqt = { version = ">=6.15.0,<6.16", channel = "mantid-ornl/label/rc" }
qtpy = "*"
muparser = "=2.3.4"
pycifrw = "*"
pyqtwebengine = "*"
git-lfs = "*"
# ------------------------------- #
# Production Environment Feature #
# ------------------------------- #
[tool.pixi.feature.prod.dependencies]
python = ">=3.10"
pip = ">=25.3"
pydantic = ">=2.7.3,<3"
# Channel-specific dependencies: Prod uses stable Mantid builds
mantidworkbench = { version = ">=6.15.0,<6.16", channel = "mantid-ornl/label/main" }
mantid = { version = ">=6.15.0,<6.16", channel = "mantid-ornl/label/main" }
mantidqt = { version = ">=6.15.0,<6.16", channel = "mantid-ornl/label/main" }
qtpy = "*"
muparser = "=2.3.4"
pycifrw = "*"
pyqtwebengine = "*"
git-lfs = "*"
# ------------------------------- #
# Local Mantid Development Feature #
# ------------------------------- #
[tool.pixi.feature.local-mantid.dependencies]
# Minimal dependencies for local Mantid development - NO mantid packages at all
python = "3.11.*"
numpy = "*"
scipy = "*"
matplotlib = "*"
h5py = "*"
psutil = "*"
qtpy = "*"
lxml = "*"
requests = "*"
toml = "*"
pyyaml = "*"
"ruamel.yaml" = "*"
# Development tools
pytest = "*"
pytest-qt = "*"
pytest-cov = "*"
ruff = "*"
# Note: We deliberately exclude ALL mantid-related packages to avoid conflicts
# The local Mantid build provides all Mantid functionality via environment variables
# Environment variables for local Mantid build
[tool.pixi.feature.local-mantid.activation.env]
MANTID_BUILD_DIR = "/path/to/mantid/build"
MANTID_BUILD_SRC = "/path/to/mantid/source"
# Use ONLY local Mantid build - no conda packages
PYTHONPATH = "src:${MANTID_BUILD_DIR}/bin:${MANTID_BUILD_SRC}/Framework/PythonInterface:${MANTID_BUILD_DIR}/qt/applications/workbench:${MANTID_BUILD_SRC}/qt/applications/workbench:${MANTID_BUILD_SRC}/qt/python/mantidqt:${MANTID_BUILD_DIR}/qt/python/mantidqtinterfaces"
LD_LIBRARY_PATH = "${MANTID_BUILD_DIR}/lib:${MANTID_BUILD_DIR}/bin"
MANTIDPATH = "${MANTID_BUILD_DIR}"
MANTID_DATA_PATH = "${MANTID_BUILD_DIR}/share/mantid"
MANTID_FRAMEWORK_PATH = "${MANTID_BUILD_DIR}/lib"
# Force Mantid to use ONLY local plugins, not conda ones
MANTID_PLUGIN_PATH = "${MANTID_BUILD_DIR}/lib"
# Prevent conda from providing any Mantid paths
CONDA_DEFAULT_ENV = ""
# Environment-specific channel configurations
[tool.pixi.feature.dev.activation.env]
# Development environment can use nightly builds
MANTID_CHANNEL_PRIORITY = "nightly"
[tool.pixi.feature.qa.activation.env]
# QA environment uses RC or prod packages
MANTID_CHANNEL_PRIORITY = "rc_prod"
[tool.pixi.feature.prod.activation.env]
# Production environment uses only stable releases
MANTID_CHANNEL_PRIORITY = "stable_only"
[tool.pixi.feature.local-mantid.tasks]
# Install SNAPRed in editable mode
install-snapred-local = { cmd = "python -m pip install -e .", description = "Install SNAPRed in editable mode into the local Mantid environment" }
# Test that local Mantid can be imported
test-local-mantid = { cmd = "python -c \"import sys; print('Python paths:'); [print(f' {p}') for p in sys.path[:5]]; print('\\\\nTesting Mantid import...'); import mantid; print(f'✅ Mantid imported from: {mantid.__file__}'); print(f'✅ Mantid version: {mantid.__version__}')\"", description = "Test that local Mantid build can be imported" }
# More comprehensive test including workbench components
test-local-mantid-full = { cmd = "python -c \"import sys; print('=== Python Environment ==='); print(f'Python executable: {sys.executable}'); print('\\\nPython paths (first 10):'); [print(f' {i+1}: {p}') for i, p in enumerate(sys.path[:10])]; print('\\\n=== Mantid Import Test ==='); import mantid; print(f'✅ Mantid imported from: {mantid.__file__}'); print(f'✅ Mantid version: {mantid.__version__}'); print('\\\n=== Workbench Components ==='); try: import mantidqt; print(f'✅ mantidqt imported from: {mantidqt.__file__}'); except Exception as e: print(f'❌ mantidqt import failed: {e}'); try: from mantidqt.utils.qt import import_qt; print('✅ Qt import successful'); except Exception as e: print(f'❌ Qt import failed: {e}')\"", description = "Comprehensive test of local Mantid build including workbench components" }
# Start SNAPRed with local Mantid build
snapred-local = { cmd = "cd $MANTID_BUILD_DIR/bin; snapred;", description = "Start SNAPRed with local Mantid build" }
# Alternative launch method using module
snapred-local-module = { cmd = "python -m snapred", description = "Start SNAPRed with local Mantid (using module import)" }
# Debug environment variables
debug-local-mantid-env = { cmd = "python -c \"import os; print('=== Environment Variables ==='); vars_to_check = ['MANTID_BUILD_DIR', 'MANTID_BUILD_SRC', 'PYTHONPATH', 'LD_LIBRARY_PATH', 'MANTIDPATH', 'MANTID_DATA_PATH', 'MANTID_FRAMEWORK_PATH']; [print(f'{var}: {os.environ.get(var, \\\"NOT SET\\\")}') for var in vars_to_check]\"", description = "Debug environment variables for local Mantid setup" }
# Comprehensive environment test
test-local-mantid-comprehensive = { cmd = "python tests/cis_tests/test_local_mantid_setup.py", description = "Comprehensive test of local Mantid environment setup" }
# Launch local Mantid Workbench with SNAPRed
launch-local-workbench = { cmd = "cd $MANTID_BUILD_DIR/bin && ./launch_mantidworkbench.sh", description = "Launch local Mantid Workbench with SNAPRed available" }