forked from metatensor/metatensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
314 lines (254 loc) · 9.31 KB
/
tox.ini
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
[tox]
# https://github.com/tox-dev/tox/issues/3238
requires = tox==4.14.0
# these are the default environments, i.e. the list of tests running when you execute
# `tox` in the command-line without anything else
envlist =
lint
core-tests
operations-numpy-tests
operations-torch-tests
learn-numpy-tests
learn-torch-tests
torch-tests
docs-tests
[testenv]
passenv = *
package = external
package_env = build-metatensor-core
lint_folders = "{toxinidir}/python" "{toxinidir}/setup.py"
build_single_wheel = --no-deps --no-build-isolation --check-build-dependencies
setenv =
# store code coverage in a per-env file, so different envs don't override each other
COVERAGE_FILE={env_dir}/.coverage
test_options =
--cov={env_site_packages_dir}/metatensor \
--cov-report= \
--import-mode=append
packaging_deps =
setuptools
setuptools-scm
packaging
wheel
cmake
testing_deps =
pytest
pytest-cov
toml
[testenv:build-metatensor-core]
# note: this is not redundant with the same value in the root [testenv] without this
# one, cmake can not find the MSVC compiler on Windows CI
passenv = *
description =
Used to only build the wheels which are then re-used by all other environments
requiring metatensor to be installed
deps =
{[testenv]packaging_deps}
commands =
pip wheel python/metatensor-core {[testenv]build_single_wheel} --wheel-dir {envtmpdir}/dist
[testenv:core-tests]
description = Run the tests of the metatensor-core Python package
deps =
numpy <2.0
{[testenv]testing_deps}
torch=={env:METATENSOR_TESTS_TORCH_VERSION:2.4.*}
changedir = python/metatensor-core
commands =
pytest {[testenv]test_options} {posargs}
[testenv:operations-numpy-tests]
description =
Run the tests of the metatensor-operations Python package using numpy arrays
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
numpy <2.0
changedir = python/metatensor-operations
commands =
# metatensor-core is installed by tox
# install metatensor-operations
pip install . {[testenv]build_single_wheel} --force-reinstall
# run the unit tests
pytest {[testenv]test_options} {posargs}
[testenv:operations-torch-tests]
description =
Run the tests of the metatensor-operations Python package using torch arrays
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
numpy <2.0
torch=={env:METATENSOR_TESTS_TORCH_VERSION:2.4.*}
changedir = python/metatensor-operations
commands =
# metatensor-core is installed by tox
# install metatensor-operations
pip install . {[testenv]build_single_wheel} --force-reinstall
# run the unit tests
pytest {[testenv]test_options} {posargs}
[testenv:learn-numpy-tests]
description =
Run the tests of the metatensor-learn Python package using numpy arrays
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
numpy <2.0
changedir = python/metatensor-learn
commands =
# metatensor-core is installed by tox
# install metatensor-operations
pip install ../metatensor-operations {[testenv]build_single_wheel} --force-reinstall
# install metatensor-learn
pip install . {[testenv]build_single_wheel} --force-reinstall
# run the unit tests
pytest {[testenv]test_options} {posargs}
[testenv:learn-torch-tests]
description =
Run the tests of the metatensor-learn Python package using torch arrays
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
torch=={env:METATENSOR_TESTS_TORCH_VERSION:2.4.*}
; used for checking equivariance
scipy
sympy
changedir = python/metatensor-learn
commands =
# metatensor-core is installed by tox
# install metatensor-torch
pip install ../metatensor-torch {[testenv]build_single_wheel} --force-reinstall
# install metatensor-operations
pip install ../metatensor-operations {[testenv]build_single_wheel} --force-reinstall
# install metatensor-learn
pip install . {[testenv]build_single_wheel} --force-reinstall
# run the unit tests
pytest {[testenv]test_options} {posargs}
[testenv:torch-tests]
description = Run the tests of the metatensor-torch Python package
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
numpy <2.0
torch=={env:METATENSOR_TESTS_TORCH_VERSION:2.4.*}
ase
changedir = python/metatensor-torch
commands =
# install metatensor-torch
pip install . {[testenv]build_single_wheel} --force-reinstall
# install metatensor-operations
pip install ../metatensor-operations {[testenv]build_single_wheel} --force-reinstall
# install metatensor-learn
pip install ../metatensor-learn {[testenv]build_single_wheel} --force-reinstall
# use the reference LJ implementation for tests
pip install {[testenv]build_single_wheel} git+https://github.com/Luthaf/metatensor-lj-test@caeb6a6
# Make torch.autograd.gradcheck works with pytest
python {toxinidir}/scripts/pytest-dont-rewrite-torch.py
# run the unit tests
pytest {[testenv]test_options} {posargs}
[testenv:docs-tests]
description = Run the doctests defined in any metatensor package
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
numpy <2.0
torch=={env:METATENSOR_TESTS_TORCH_VERSION:2.4.*}
ase
setenv =
# ignore the fact that metatensor.torch.operations was loaded from a file
# not in `metatensor/torch/operations`
PY_IGNORE_IMPORTMISMATCH = 1
commands =
# metatensor-core is installed by tox
# install metatensor
pip install . {[testenv]build_single_wheel} --force-reinstall
# install metatensor-operations
pip install python/metatensor-operations {[testenv]build_single_wheel} --force-reinstall
# install metatensor-learn
pip install python/metatensor-learn {[testenv]build_single_wheel} --force-reinstall
# install metatensor-torch
pip install python/metatensor-torch {[testenv]build_single_wheel} --force-reinstall
# run documentation tests
pytest --doctest-modules --pyargs metatensor
[testenv:lint]
description =
lint the Python code with flake8 (code linter), black (code formatter), and
isort (sorting of imports)
package = skip
deps =
flake8
flake8-bugbear
black
blackdoc
isort
commands =
flake8 --extend-exclude "*/build/*" {[testenv]lint_folders}
black --check --diff {[testenv]lint_folders}
blackdoc --check --diff {[testenv]lint_folders}
isort --check-only --diff --extend-skip-glob "*/build/*" {[testenv]lint_folders}
[testenv:format]
description = Abuse tox to do actual formatting on all files.
package = skip
deps =
black
blackdoc
isort
commands =
black {[testenv]lint_folders}
blackdoc {[testenv]lint_folders}
isort {[testenv]lint_folders}
[testenv:docs]
description = build the documentation with sphinx
deps =
{[testenv]packaging_deps}
cmake
sphinx == 7.4.*
sphinx-toggleprompt # hide the prompt (>>>) in python doctests
sphinx-gallery # convert python files into nice documentation
pygments # syntax highligthing
breathe # C and C++ => sphinx through doxygen
furo # sphinx theme
myst_parser # include markdown documents in sphinx
sphinx-design # helpers for nicer docs website (tabs, grids, cards, …)
sphinxcontrib-details-directive # hide some information by default in HTML
# required for autodoc
numpy <2.0
torch=={env:METATENSOR_TESTS_TORCH_VERSION:2.4.*}
# required for examples
ase
chemiscope
allowlist_externals = bash
commands =
# metatensor-core is installed by tox
# install metatensor
pip install . {[testenv]build_single_wheel} --force-reinstall
# install metatensor-operations
pip install python/metatensor-operations {[testenv]build_single_wheel} --force-reinstall
# install metatensor-torch
pip install python/metatensor-torch {[testenv]build_single_wheel} --force-reinstall
# install metatensor-learn
pip install python/metatensor-learn {[testenv]build_single_wheel} --force-reinstall
sphinx-build -d docs/build/doctrees -W -b html docs/src docs/build/html
bash -c "cargo rustdoc --package metatensor -- --html-before-content docs/src/core/reference/rust/backlink.html"
bash -c "rm -rf docs/build/html/core/reference/rust/"
bash -c "cp -r target/doc/ docs/build/html/core/reference/rust/"
bash -c "cp docs/src/core/reference/rust/index.html docs/build/html/core/reference/rust/"
[testenv:build-tests]
description = Asserts Pythons package build integrity so one can build sdist and wheels
package = skip
deps =
build
twine # a tool to check sdist and wheels metadata
pip2pi # tool to create PyPI-like package indexes
allowlist_externals = bash
commands =
python --version # print the version of python used in this test
bash ./scripts/build-all-wheels.sh {envtmpdir}
twine check {envtmpdir}/dist/*.tar.gz
twine check {envtmpdir}/dist/*.whl
# check building wheels directly from the a checkout
python -m build python/metatensor-core --wheel --outdir {envtmpdir}/dist
python -m build python/metatensor-operations --wheel --outdir {envtmpdir}/dist
python -m build python/metatensor-learn --wheel --outdir {envtmpdir}/dist
python -m build python/metatensor-torch --wheel --outdir {envtmpdir}/dist
python -m build . --wheel --outdir {envtmpdir}/dist
[flake8]
max_line_length = 88
extend-ignore = E203