-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtox.ini
230 lines (187 loc) · 7.87 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
[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
torch-tests
torch-tests-cxx
torch-install-tests-cxx
docs-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
test_options =
--cov={env_site_packages_dir}/metatomic \
--cov-report= \
--import-mode=append
packaging_deps =
setuptools
packaging
cmake
testing_deps =
pytest
pytest-cov
metatensor_deps =
metatensor-torch >=0.7.0,<0.8.0
metatensor-operations >=0.3.0,<0.4.0
[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 =
{[testenv]packaging_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.5}.*
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.5}.*
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.5}/ \
-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.5}.*
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.5}/ \
-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.5}/\;\
{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.5}/ \
-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}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.5}.*
numpy
vesin
ase
# for metatensor-lj-test
setuptools-scm
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@ad24de3
# Make torch.autograd.gradcheck works with pytest
python {toxinidir}/scripts/pytest-dont-rewrite-torch.py
pytest {[testenv]test_options} {posargs}
[testenv:docs-tests]
description = Run the doctests defined in any metatomic package
deps =
{[testenv]testing_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.5}.*
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
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
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.5}.*
# required for examples
ase
chemiscope
commands =
sphinx-build -d docs/build/doctrees -W -b html docs/src docs/build/html