-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtox.ini
151 lines (135 loc) · 6.63 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
;Environment, package and testing specifications for tox.
;Run this using 'tox -r --develop -c tox.ini' from a non-conda environment that has tox, but not tox-conda, installed.
;See below for more details
;Note that there is a well known bug that tox doesn't realize if the requirements.txt file has changed between runs.
;See e.g. here https://tox.wiki/en/latest/example/general.html or here https://github.com/tox-dev/tox/issues/149
;To avoid any resulting bugs, always start tox using the '-r' flag, to force a rebuild of the virtual envs everytime.
;The '--develop' option is used so that tox doesn't try to install the package using pypi, which can't work as scan
;isn't on there yet, and instead runs 'pip install -e .' behind the scenes.
;tox-conda and python interpreter notes:
;To be able to test both a normal pip installation, as well as one using conda environments, we use tox-conda to allow
;conda_deps and conda-spec to specify the packages that should be installed using conda, instead of pip. in the c-*
;environments, while we use the normal pip and virtual envs in the pe-* environments
;Using that plugin changes the way that python versions are found by tox in a way that I frankly don't quite
;understand. Additionally you can't turn tox-conda on/off on and environment basis, only globally for the whole tox
;project (see https://github.com/tox-dev/tox-conda/issues/36). Annoyingly, just manually specifying the the pip
;and conda python interpreters we want to use is not enough to make the tox-conda plugin work correctly, as the creation
;of the environments themselves must be done with conda.
;As such, the seemingly only way to use conda and pip for the same project is to specify two .ini files, one for pip,
;one for conda..
;To run this tox.ini with the correct setup, install pyenv (https://github.com/pyenv/pyenv#basic-github-checkout) and
;pyenv-virtualenv (https://github.com/pyenv/pyenv-virtualenv) and create 4 virtual environments with python-versions 3.6
;to 3.9 and tox installed. The following should work. First install the python version you want to test against with
;pyenv:
;pyenv install 3.6.15
;pyenv install 3.7.13
;pyenv install 3.8.13
;pyenv install 3.9.12
;Then create the virtualenvironments in question and install tox there (technically only one of them needs to have tox,
;but this way is safer):
;pyenv virtualenv 3.6.15 pe_tox_py36
;pyenv activate pe_tox_py36
;pip install tox
;pyenv deactivate
;pyenv virtualenv 3.7.13 pe_tox_py37
;pyenv activate pe_tox_py37
;pip install tox
;pyenv deactivate
;pyenv virtualenv 3.8.13 pe_tox_py38
;pyenv activate pe_tox_py37
;pip install tox
;pyenv deactivate
;pyenv virtualenv 3.9.12 pe_tox_py39
;pyenv activate pe_tox_py37
;pip install tox
;pyenv deactivate
;Then, set these pyenv virtual environments as local versions for this repository's folder. e.g:
;pyenv local pe_tox_py36 pe_tox_py37 pe_tox_py38 pe_tox_py39
;Then you can run the tests specified in this ini by using:
;tox -r --develop -c tox.ini
;To run the tox-conda.ini file with the correct setup, you just need to have conda installed on your system. Then use:
;tox -r --develop -c tox-conda.ini
;Surprisingly(?), the pyenv setup from above does not interfere with the conda setup at all, as each python version is
;installed fresh from the conda servers if tox-conda is used.
;Also note that, if you want to change the python version an evironment, you have to delete the .tox folder containing
;the already built environments. Otherwise it will just use whatever is in there, even if you tell tox not to.
;Similarly, if you change the setup.py, you should always delete scan.egg-info, as otherwise outdated info might be
;used to try installing the package. To be save, just use:
;rm -rf .tox && rm -rf scan.egg-info && tox -r --develop -c tox.ini
;or
;rm -rf .tox && rm -rf scan.egg-info && tox -r --develop -c tox-conda.ini
;respectively
;VERY IMPORTANT: Do not have underscores in any of the environment names, for some reason tox can't deal with them!
;Also note that these names are not just names, but there is quite a bit of substitution and pattern matching going on.
;See the tox docs for more details.
[tox]
envlist =
; pe-py{36,37,38,39,310}-current
; pe-py{36,37,38,39,310}-oldest-supported
; pe-py{36,37,38,39,310}-newest-supported
; pe-py{36,37,38,39,310}-cutting-edge
pe-py{38,39,310}-current
pe-py{38,39,310}-oldest-supported
pe-py{38,39,310}-newest-supported
pe-py{38,39,310}-cutting-edge
;Use the editable install for testing, as that's the one most/all of the packages uses will be done with too
usedevelop = true
[pe-common-deps]
;deps arguments are passed to pip
;The --no-cache-dir is needed for mpi4py as pip's cached version sometimes uses the wrong mpicc compiler, depending on
;what/how mpi4py was installed in the past
deps =
--upgrade
--no-cache-dir
tox
pytest
pytest-mpi==0.6
extras = mpi
[pe-requirements-current]
deps =
-r{toxinidir}{/}requirements.txt
[pe-requirements-oldest-supported]
deps =
py36: -r{toxinidir}{/}tox_requirements{/}requirements_oldest_supported_py36.txt
py37: -r{toxinidir}{/}tox_requirements{/}requirements_oldest_supported_py37.txt
py38: -r{toxinidir}{/}tox_requirements{/}requirements_oldest_supported_py38.txt
py39: -r{toxinidir}{/}tox_requirements{/}requirements_oldest_supported_py39.txt
py310: -r{toxinidir}{/}tox_requirements{/}requirements_oldest_supported_py310.txt
; py311: -r{toxinidir}{/}tox_requirements{/}requirements_oldest_supported_py311.txt
[pe-requirements-newest-supported]
deps =
-r{toxinidir}{/}tox_requirements{/}requirements_newest_supported.txt
[pe-requirements-cutting-edge]
deps =
-r{toxinidir}{/}tox_requirements{/}requirements_cutting_edge.txt
[testenv:pe-py{36,37,38,39,310,311}-{current,oldest-supported,newest-supported,cutting-edge}]
;basepython =
; py36: {homedir}{/}.pyenv{/}versions{/}pe_tox_py36{/}bin{/}python
; py37: {homedir}{/}.pyenv{/}versions{/}pe_tox_py37{/}bin{/}python
; py38: {homedir}{/}.pyenv{/}versions{/}pe_tox_py38{/}bin{/}python
; py39: {homedir}{/}.pyenv{/}versions{/}pe_tox_py39{/}bin{/}python
;install_command =
; pip install --no-cache-dir {opts} {packages}
deps =
{[pe-common-deps]deps}
current: {[pe-requirements-current]deps}
oldest-supported: {[pe-requirements-oldest-supported]deps}
newest-supported: {[pe-requirements-newest-supported]deps}
cutting-edge: {[pe-requirements-cutting-edge]deps}
extras =
{[pe-common-deps]extras}
[testenv]
allowlist_externals =
which
type
conda
echo
mpiexec
mpiexec.hydra
commands =
python --version
pip list
which mpiexec
mpiexec --version
pytest
mpiexec -n 3 pytest tests/test_mpi.py --with-mpi