-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtox.ini
144 lines (130 loc) · 6.22 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
;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 rescomp
;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 rescomp.egg-info, as otherwise outdated info might be
;used to try installing the package. To be save, just use:
;rm -rf .tox && rm -rf rescomp.egg-info && tox -r --develop -c tox.ini
;or
;rm -rf .tox && rm -rf rescomp.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-py36-current
; pe-py{37,38}-current
; pe-py{36}-oldest-supported
; pe-py{37}-oldest-supported
; pe-py{38}-oldest-supported
; pe-py{39}-oldest-supported
pe-py{36,37,38,39}-current
pe-py{36,37,38,39}-oldest-supported
pe-py{36,37,38,39}-newest-supported
pe-py{36,37,38,39}-cutting-edge
[pe-common-deps]
deps =
tox
pytest
[pe-requirements-current]
deps =
-Ur{toxinidir}{/}requirements.txt
[pe-requirements-oldest-supported]
deps =
py36: -Ur{toxinidir}{/}env_specs{/}requirements_oldest_supported_py36.txt
py37: -Ur{toxinidir}{/}env_specs{/}requirements_oldest_supported_py37.txt
py38: -Ur{toxinidir}{/}env_specs{/}requirements_oldest_supported_py38.txt
py39: -Ur{toxinidir}{/}env_specs{/}requirements_oldest_supported_py39.txt
[pe-requirements-newest-supported]
deps =
-Ur{toxinidir}{/}env_specs{/}requirements_newest_supported.txt
[pe-requirements-cutting-edge]
deps =
-Ur{toxinidir}{/}env_specs{/}requirements_cutting_edge.txt
[testenv:pe-py{36,37,38,39}-{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
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}
[testenv]
allowlist_externals =
which
type
conda
echo
commands =
; echo "--------------------------------------------------------------------------------"
; which python
; python -V
; echo "--------------------------------------------------------------------------------"
; which pip
; pip -V
; python -m pip -V
; which tox
; tox --version
; which conda
; conda -V
pip list
; conda list
; which pytest
; python -m pytest -v --tb=no
pytest -v --tb=no