-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtox.ini
152 lines (140 loc) · 3.79 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
[tox]
envlist = py311, py312
isolated_build = true
requires = tox>4
deps =
setuptools-scm
cython ~= 3.0
setenv =
# forcibly enable pytest colors
PY_COLORS = 1
# disable pkgcore's pytest plugin
PYTEST_ADDOPTS = -p no:pkgcore
[testenv]
skip_sdist = true
skip_install = true
passenv =
CFLAGS
LDFLAGS
PKG_CONFIG_PATH
setenv =
# run tests against in-place build for doctest and coverage support
PYTHONPATH = {toxinidir}/src
{[tox]setenv}
deps =
{[tox]deps}
pytest
pytest-cython
[testenv:python]
description = run tests for default system python
commands =
python setup.py build_ext --inplace --develop
# run doctests
pytest --doctest-cython src/pkgcraft
# run regular tests
pytest {posargs}
# Note that old, non-coverage-enabled, cythonized modules need to be removed
# for coverage to work properly.
[testenv:coverage]
description = run tests while recording code coverage data
deps =
coverage
{[testenv]deps}
commands =
# build cython extensions with coverage enabled
python setup.py build_ext --inplace --cython-coverage --develop
# run doctests
coverage run -m pytest --doctest-cython src/pkgcraft
# run regular tests
coverage run -m pytest {posargs}
coverage combine
# generate coverage file for codecov
coverage xml
coverage report
coverage html
[testenv:valgrind]
description = run tests under valgrind to find memory handling issues
allowlist_externals = valgrind
commands =
python setup.py build_ext --inplace
# run doctests
valgrind pytest --doctest-cython src/pkgcraft
# run regular tests, skipping parallelized ones that cause failures
valgrind pytest -m "not parallel" {posargs}
[testenv:bench]
description = run benchmarks against pkgcore, portage, and others
base = tox
deps =
ordered-set
pytest-benchmark
pkgcore
portage
commands =
pytest {posargs} benches --benchmark-group-by=func --benchmark-warmup=on
[testenv:membench]
description = run memory usage benchmarks
base = tox
allowlist_externals = bash
deps =
pkgcore
portage
humanize
psutil
commands =
bash -c "python {toxinidir}/membench/*.py"
[testenv:lint]
description = run various code linting procedures
allowlist_externals = bash
deps =
cython-lint
isort
pylint
black
commands =
# check for cython issues, ignoring file generated by cbindgen
bash -c "shopt -s extglob globstar nullglob; GLOBIGNORE='src/*/C.pxd'; cython-lint --max-line-length 100 src/**/*.p{yx,xd}"
# check for improperly formatted imports in non-generated files
isort -s C.pxd --check-only --diff benches membench doc examples src tests setup.py
# check for unused imports
bash -c "pylint --score=no --disable=all --enable=W0611,W0612,W0613 benches membench doc/conf.py tests examples/* setup.py"
# verify formatting
black --check .
[testenv:format]
description = auto-format code using various procedures
deps =
isort
black
commands =
isort -s C.pxd benches membench doc/conf.py examples src tests setup.py
black .
[testenv:doc]
description = generate documentation
allowlist_externals = make
deps =
{[tox]deps}
sphinx
sphinx-autodoc-typehints
commands =
python setup.py build_ext --inplace --doc
make -C doc html
[testenv:cbindgen]
description = generate C bindings
allowlist_externals =
bash
cbindgen
deps =
passenv =
# path to the pkgcraft-c repo
PKGCRAFT_C_PATH
commands =
bash -c "[[ -n ${PKGCRAFT_C_PATH} ]] && cbindgen -q --config cbindgen.toml ${PKGCRAFT_C_PATH} | sed 's/;$//' > src/pkgcraft/C.pxd"
[testenv:sdist]
description = build the source distribution
deps = build
commands = python -m build --sdist
[testenv:install]
description = install pkgcraft, pkgcore, and portage in a venv
base = tox
deps =
pkgcore
portage