forked from metatensor/metatomic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtox.ini
More file actions
284 lines (231 loc) · 9.54 KB
/
tox.ini
File metadata and controls
284 lines (231 loc) · 9.54 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
[tox]
# https://github.com/tox-dev/tox/issues/3238
requires = tox >=4.39
# 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
torch-tests
torch-tests-cxx
torch-install-tests-cxx
docs-tests
torchsim-tests
[testenv]
passenv = *
setenv =
# Do not use the user PYTHONPATH, tox is handling everything
PYTHONPATH=
# store code coverage in a per-env file, so different envs don't override each other
COVERAGE_FILE={env_dir}/.coverage
package = external
package_env = build-metatomic-torch
lint_folders = "{toxinidir}/python" "{toxinidir}/setup.py"
build_single_wheel = --no-deps --no-build-isolation --check-build-dependencies
packaging_deps =
setuptools >= 77
packaging >=26
cmake
testing_deps =
pytest
pytest-cov
metatensor_deps =
metatensor-torch >=0.8.0,<0.9
metatensor-operations >=0.4.0,<0.5
[testenv:build-metatomic-torch]
# 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 = *
setenv =
# Do not use the user PYTHONPATH, tox is handling everything
PYTHONPATH=
description =
Used to only build the wheels which are then re-used by all other environments
requiring metatomic-torch to be installed
deps =
pip
{[testenv]packaging_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
commands =
pip wheel python/metatomic_torch {[testenv]build_single_wheel} --wheel-dir {envtmpdir}/dist
################################################################################
##### C++ tests setup #####
################################################################################
[testenv:torch-tests-cxx]
description = Run the C++ tests for metatomic-torch
package = skip
deps =
cmake
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
commands =
# configure cmake
cmake -B {env_dir}/build metatomic-torch \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.10}/ \
-DMETATOMIC_TORCH_TESTS=ON
# build code with cmake
cmake --build {env_dir}/build --config Debug --parallel
# run all tests
ctest --test-dir {env_dir}/build --build-config Debug --output-on-failure
[testenv:torch-install-tests-cxx]
description = Run the C++ tests for metatomic-torch
package = skip
deps =
cmake
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
commands =
# configure, build and install metatomic-torch
cmake -B {env_dir}/build-metatomic-torch metatomic-torch \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX={env_dir}/usr/ \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.10}/ \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
cmake --build {env_dir}/build-metatomic-torch --config Debug --parallel --target install
# try to use the installed metatomic-torch from another CMake project
cmake -B {env_dir}/build-find-package metatomic-torch/tests/cmake-project \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.10}/;\
{env_dir}/usr/ \
-DUSE_CMAKE_SUBDIRECTORY=OFF
cmake --build {env_dir}/build-find-package --config Debug --parallel
ctest --test-dir {env_dir}/build-find-package --build-config Debug --output-on-failure
# Same, but using metatomic-torch as a CMake subdirectory
cmake -B {env_dir}/build-subdirectory metatomic-torch/tests/cmake-project \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.10}/ \
-DUSE_CMAKE_SUBDIRECTORY=ON
cmake --build {env_dir}/build-subdirectory --config Debug --parallel
ctest --test-dir {env_dir}/build-subdirectory --build-config Debug --output-on-failure
################################################################################
##### Python tests setup #####
################################################################################
[testenv:torch-tests]
description = Run the tests of the metatomic-torch Python package
deps =
{[testenv]testing_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
numpy {env:METATOMIC_TESTS_NUMPY_VERSION_PIN}
vesin
ase
# for metatensor-lj-test
setuptools-scm
cmake
pip
# for symmetrized calculator
scipy
spglib
# uncomment for testing nvalchemiops integration on GPU (requires Python 3.11+)
# nvalchemi-toolkit-ops
changedir = python/metatomic_torch
commands =
# use the reference LJ implementation for tests
pip install {[testenv]build_single_wheel} git+https://github.com/metatensor/lj-test@f7401a8
# Make torch.autograd.gradcheck works with pytest
python {toxinidir}/scripts/pytest-dont-rewrite-torch.py
pytest --cov={env_site_packages_dir}/metatomic --cov-report= --import-mode=append {posargs}
[testenv:build-metatomic-torchsim]
passenv = *
setenv =
PYTHONPATH=
description =
Build the metatomic-torchsim wheel for testing
deps =
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
commands =
pip wheel python/metatomic_torchsim {[testenv]build_single_wheel} --wheel-dir {envtmpdir}/dist
[testenv:torchsim-tests]
description = Run the tests of the metatomic-torchsim Python package
package = external
package_env = build-metatomic-torch
deps =
{[testenv]testing_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
numpy {env:METATOMIC_TESTS_NUMPY_VERSION_PIN}
vesin
ase
torch-sim-atomistic
# for metatensor-lj-test
setuptools-scm
cmake
changedir = python/metatomic_torchsim
commands =
# install metatomic-torchsim
pip install {[testenv]build_single_wheel} {toxinidir}/python/metatomic_torchsim
# use the reference LJ implementation for tests
pip install {[testenv]build_single_wheel} git+https://github.com/metatensor/lj-test@f7401a8
pytest --cov={env_site_packages_dir}/metatomic_torchsim --cov-report= --import-mode=append {posargs}
[testenv:docs-tests]
description = Run the doctests defined in any metatomic package
deps =
{[testenv]testing_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
numpy {env:METATOMIC_TESTS_NUMPY_VERSION_PIN}
vesin
ase
commands =
pytest --doctest-modules --pyargs metatomic
################################################################################
##### Linter and formatter setup #####
################################################################################
[testenv:lint]
description = Run linters and type checks
package = skip
deps =
ruff
commands =
ruff format --diff {[testenv]lint_folders}
ruff check {[testenv]lint_folders}
[testenv:format]
description = Abuse tox to do actual formatting on all files.
package = skip
deps =
ruff
commands =
ruff format {[testenv]lint_folders}
ruff check --fix-only {[testenv]lint_folders}
################################################################################
##### Documentation building #####
################################################################################
[testenv:docs]
description = build the documentation with sphinx
setenv =
# build the docs against the CPU only version of torch
PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu {env:PIP_EXTRA_INDEX_URL:}
deps =
{[testenv]packaging_deps}
{[testenv]testing_deps}
sphinx == 7.4.*
sphinx-toggleprompt # hide the prompt (>>>) in python doctests
sphinx-gallery # convert python files into nice documentation
sphinx-sitemap # automatically generates sitemap
pygments # syntax highlighting
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
setuptools <82 # required for sphinxcontrib-details-directive
# required for autodoc
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.10}.*
torch-sim-atomistic >=0.5,<0.6
# required for examples
ase
chemiscope
commands =
pip install {[testenv]build_single_wheel} {toxinidir}/python/metatomic_torchsim
sphinx-build -d docs/build/doctrees -W -b html docs/src docs/build/html