forked from THGLab/MCSCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
211 lines (194 loc) · 5.58 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
[tox]
minversion = 3.14.0
ignore_basepython_conflict = true
# these are the environments that will run when you
# execute `tox` in the command-line
# bellow you will find explanations for all environments
envlist =
build
docs
py37
py38
py39
# helps runnings tox with github actions
# from: https://github.com/ymyzk/tox-gh-actions
[gh-actions]
python =
3.7: py37, build, docs
# configures which environments run with each python version
[testenv]
basepython =
{py37,docs}: {env:TOXPYTHON:python3.7}
{py38}: {env:TOXPYTHON:python3.8}
{py39}: {env:TOXPYTHON:python3.9}
{build,prreqs,lint,radon,safety}: {env:TOXPYTHON:python3}
passenv = *
#deps = -r{toxinidir}/cirequirements.txt
# configures the unittest environment for python 3.6
[testenv:py37]
setenv =
PYTHONPATH={toxinidir}/tests
PYTHONUNBUFFERED=yes
user_develop = false
# installs dependencies we need for testing
# by using tox the developer don't need to manage this dependencies
# him/herself
deps =
numpy>=1,<2
scipy>=1,<2
numba>=0.53
coverage
pytest
pytest-cov
hypothesis
# before running the tests erases any prerecord of coverage
commands_pre =
coverage erase
# execute pytest
commands =
pytest --cov --cov-report=term-missing --cov-append --cov-config=.coveragerc -vv --hypothesis-show-statistics {posargs}
# after executing the pytest assembles the coverage reports
commands_post =
coverage report
coverage html
coverage xml
# in previous verions I had independent environments to manage the
# coverage reports. However, I found that doing such as pre and post
# commands facilitates many configuration details
[testenv:py39]
setenv = {[testenv:py37]setenv}
user_develop = {[testenv:py37]user_develop}
deps = {[testenv:py37]deps}
commands_pre = {[testenv:py37]commands_pre}
commands = {[testenv:py37]commands}
commands_post = {[testenv:py37]commands_post}
[testenv:py38]
setenv = {[testenv:py37]setenv}
user_develop = {[testenv:py37]user_develop}
deps = {[testenv:py37]deps}
commands_pre = {[testenv:py37]commands_pre}
commands = {[testenv:py37]commands}
commands_post = {[testenv:py37]commands_post}
# separates lint from build env
[testenv:lint]
deps =
flake8>=3
flake8-docstrings
flake8-bugbear
pygments
git+git://github.com/timothycrosley/isort.git
skip_install = true
commands =
flake8 {posargs:src tests setup.py docs}
isort --verbose --check-only --diff src tests setup.py
# confirms changelog was updated after new code additions
# see .bumpversion.cfg and documentation
# https://python-project-skeleton.readthedocs.io/en/latest/contributing.html#update-changelog
[testenv:prreqs]
skip_install = true
commands = python {toxinidir}/devtools/check_changelog.py
# asserts package build integrity
[testenv:build]
# setenv here integrates with commit message in .bumpversion.cfg
# we can tests bump2version with an actual commit
setenv =
COMMIT_MSG = Test commit message
# dependencies needed for code quality checks
# you need to add here any additional dependencies you might need
deps =
setuptools
wheel
twine
docutils
check-manifest
readme-renderer
bump2version
skip_install = true
commands_pre = python {toxinidir}/devtools/clean_dist_check.py
commands =
python --version
python setup.py sdist bdist_wheel
twine check dist/*.whl
twine check dist/*.tar.gz
check-manifest {toxinidir}
bump2version --dry-run --verbose --allow-dirty patch
bump2version --dry-run --verbose --allow-dirty minor
bump2version --dry-run --verbose --allow-dirty major
commands_post = python {toxinidir}/devtools/clean_dist_check.py
# code quality assessment. This is not a check in the CI, serves just
# as info for the developer
[testenv:radon]
deps = radon
skip_install = true
commands =
radon cc -s --total-average --no-assert -nb src/
radon mi -m -s src/
# Simulate docs building as it will occur on ReadTheDocs
# if this fails, most likely RTD build will fail
[testenv:docs]
usedevelop = true
deps =
-r{toxinidir}/devtools/docs_requirements.txt
commands =
sphinx-build {posargs:-E} -b html docs/rst dist/docs
#sphinx-build -b linkcheck docs dist/docs
# safety checks
[testenv:safety]
deps = safety
skip_install = true
commands = safety check
# my favourite configuration for flake8 styling
# https://flake8.pycqa.org/en/latest/#
[flake8]
max_line_length = 80
hang-closing = true
ignore =
W293
W503
D412
D105
per-file-ignores = setup.py:E501
docstring-convention = numpy
# normally I exclude init because it is very hard to configure init
# without breaking many rules
exclude = src/sampleproject/__init__.py
# configuration for the isort module
# https://github.com/timothycrosley/isort
[isort]
skip = __init__.py
line_length = 80
indent = 4
multi_line_output = 8
include_trailing_comma = true
lines_after_imports = 2
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
#known_future_library=future,pies
#known_standard_library=std,std2
known_first_party = mcsce
# you should add here your known thirdparties, it will facilitate
# the job to isort
known_third_party =
hypothesis
matplotlib
numpy
pytest
[tool:pytest]
# If a pytest section is found in one of the possible config files
# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others,
# so if you add a pytest config section elsewhere,
# you will need to delete this section from setup.cfg.
#norecursedirs =
#migrations
addopts = -p pytest_cov
python_files =
test_*.py
*_test.py
tests.py
#addopts =
# -ra
# --strict
# --doctest-modules
# --doctest-glob=\*.rst
# --tb=short
testpaths =
tests