forked from metatensor/featomic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtox.ini
185 lines (141 loc) · 4.42 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
[tox]
min_version = 4.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
all-deps
min-deps
docs-tests
torch-tests
[testenv]
package = external
package_env = build-rascaline
passenv = *
lint-folders = "{toxinidir}/python" "{toxinidir}/setup.py"
# we need to manually install dependencies for rascaline, since tox will install
# the fresh wheel with `--no-deps` after building it.
metatensor-core-requirement =
metatensor-core @ git+https://github.com/lab-cosmo/metatensor@ae10944\#subdirectory=python/metatensor-core
metatensor-torch-requirement =
metatensor-torch @ git+https://github.com/lab-cosmo/metatensor@ae10944\#subdirectory=python/metatensor-torch
build-single-wheel = --no-deps --no-build-isolation --check-build-dependencies
commands =
# error if the user gives a wrong testenv name in `tox -e`
python -c "import sys; print('environement {env_name} does not exist'); sys.exit(1)"
[testenv:build-rascaline]
# This environment is only used to build the wheels which are then re-used by
# all other environments requiring rascaline to be installed
passenv = *
deps =
setuptools
wheel
cmake
commands =
pip wheel . {[testenv]build-single-wheel} --wheel-dir {envtmpdir}/dist
[testenv:all-deps]
# Run Python unit tests with all dependencies installed (ase & chemfiles are
# optional dependencies)
deps =
{[testenv]metatensor-core-requirement}
ase
chemfiles
pytest
pytest-cov
commands =
pytest --cov={env_site_packages_dir}/rascaline --cov-report xml:.tox/coverage.xml --import-mode=append {posargs}
[testenv:min-deps]
# Run Python unit tests with the minimal dependencies installed
deps =
{[testenv]metatensor-core-requirement}
pytest
commands =
pytest --import-mode=append {posargs}
[testenv:torch-tests]
deps =
{[testenv]metatensor-torch-requirement}
pytest
numpy
torch
ase
cmake
wheel
changedir = python/rascaline-torch
commands =
# install rascaline-torch
pip install . {[testenv]build-single-wheel} --force-reinstall
# run the unit tests
pytest --import-mode=append --assert=plain {posargs}
[testenv:docs]
deps =
-r docs/requirements.txt
cmake
build
allowlist_externals =
bash
commands =
# install rascaline-torch
pip install python/rascaline-torch --no-deps --no-build-isolation --force-reinstall
bash -c "rm -rf docs/src/examples"
sphinx-build {posargs:-E} -W -b html docs/src docs/build/html
[testenv:docs-tests]
# this environement runs the doctests defined in any metatensor package
deps =
{[testenv]metatensor-core-requirement}
ase
pytest
commands =
pytest --doctest-modules --pyargs rascaline
[testenv:lint]
# lint the Python code with flake8 (code linter), black (code formatter), and
# isort (sorting of imports)
package = skip
deps =
black
blackdoc
flake8
flake8-bugbear
flake8-sphinx-links
isort
commands =
flake8 {[testenv]lint-folders}
black --check --diff {[testenv]lint-folders}
blackdoc --check --diff {[testenv]lint-folders}
isort --check-only --diff {[testenv]lint-folders}
[testenv:format]
package = skip
# Abuse tox to do actual formatting. Users can call `tox -e format` to run
# formatting on all files
deps =
black
blackdoc
isort
commands =
black {[testenv]lint-folders}
blackdoc {[testenv]lint-folders}
isort {[testenv]lint-folders}
[testenv:build-python]
package = skip
# Make sure we can build sdist and a wheel for python
deps =
twine
build
allowlist_externals =
bash
commands =
python --version # print the version of python used in this test
bash ./scripts/package-torch.sh
bash -c "rm -rf {envtmpdir}/dist"
# check building sdist from a checkout, and wheel from the sdist
python -m build . --outdir {envtmpdir}/dist
# for rascaline-torch, we can not build from a sdist until rascaline
# is available on PyPI, so we build both sdist and wheel from a checkout
python -m build python/rascaline-torch --sdist --outdir {envtmpdir}/dist
python -m build python/rascaline-torch --wheel --outdir {envtmpdir}/dist
twine check {envtmpdir}/dist/*.tar.gz
twine check {envtmpdir}/dist/*.whl
# check building wheels directly from the a checkout
python -m build . --wheel --outdir {envtmpdir}/dist
[flake8]
max_line_length = 88
extend-ignore = E203