-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.cfg
More file actions
230 lines (205 loc) · 6.59 KB
/
setup.cfg
File metadata and controls
230 lines (205 loc) · 6.59 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# build_clib and build_ext are dynamically changed when "poetry build" or "poetry install" commands are executed
# used mingw32 into MSYS2 by poetry build on windows, otherwise MSVC is used and build fails
# https://stackoverflow.com/questions/36189453/how-to-change-python-default-compiler-to-gcc
# https://wiki.python.org/moin/WindowsCompilers
[build_clib]
compiler = mingw32
# used mingw32 into MSYS2 by poetry build on windows, otherwise MSVC is used and build fails
[build_ext]
compiler = mingw32
# to avoid building package under windows (that fails), execute tox with
# poetry run tox --skip-pkg-install --direct-yolo -e ...
# ref https://stackoverflow.com/questions/16737260/how-to-tell-distutils-to-use-gcc
# ref https://github.com/gpongelli/cookiecutter-pylibrary/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/ci/templates/.github/workflows/github-actions.yml
[flake8]
max-line-length = 120
max-complexity = 18
ignore = E203, E266, W503, D301
docstring-convention = google
doctests = True
per-file-ignores =
__init__.py:F401
pycode128/cli_tools/cli.py:DAR101
exclude = .git,
__pycache__,
setup.py,
build,
dist,
docs,
releases,
.venv,
.tox,
.mypy_cache,
.pytest_cache,
.vscode,
.github,
[mypy]
ignore_missing_imports = True
show_error_codes = True
[darglint]
strictness = full
docstring_style = google
message_template = {path}:{line} @{obj} {msg_id}: {msg}
ignore_regex = ^_(.*)|pycode128|main
[tool:pytest]
testpaths = tests
addopts =
--cov
--cov-report=term-missing
--cov=pycode128
--cov-append
[coverage:run]
# uncomment the following to omit files during running
#omit =
# path/folder/file
# path/folder/*
branch = True
[coverage:report]
show_missing = True
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.:
def main
[coverage:html]
directory = coverage_html
show_contexts = True
[gh-actions]
python =
3.9: py39, format, lint, build
[tox:tox]
min_version = 4.0 # platform specification support is available since version 2.0
isolated_build = true
envlist = lint, format, py{3.8, 3.9, 3.10, 3.11}-{lin,mac,win}
[dev]
allowlist_externals =
poetry
python
commands =
poetry run python --version
# python --version
poetry lock --no-update
poetry install -v --with devel --no-root --sync
poetry run tox --version
poetry run pip --version
poetry run pip list --format=freeze
[testenv]
description = Run tests
platform = lin: linux
mac: darwin
win: win32
allowlist_externals =
{[dev]allowlist_externals}
passenv = *
setenv =
py3.8-{lin, mac}: PYTH = python3.8
py3.9-{lin, mac}: PYTH = python3.9
py3.10-{lin, mac}: PYTH = python3.10
py3.11-{lin, mac}: PYTH = python3.11
py{3.8, 3.9, 3.10, 3.11}-{win}: PYTH = python
COVERAGE_FILE = .coverage_{envname}
PYTHONPATH = {toxinidir}
PYTHONWARNINGS = ignore
commands_pre =
# poetry needs name of python binary
poetry env use {env:PYTH}
# in case of C/C++ extension, it's better to rebuild package for every python version & env
{[testenv:build]commands}
commands =
# poetry install -v
# install the package or pytest cannot find it
poetry install
poetry run pytest {posargs:-vv} --cov-report=html:html_coverage_{envname} --cov-report=xml:xml_coverage_{envname}.xml
# pytest --cov=pycode128 --cov-branch --cov-report=xml --cov-report=term-missing tests
[testenv:format]
description = Format the code
ignore_errors = True
skip_install = true
allowlist_externals =
{[dev]allowlist_externals}
commands_pre =
{[dev]commands}
commands =
poetry run isort pycode128 tests build_extension.py
poetry run black pycode128 tests build_extension.py
[testenv:license]
description = License files according to REUSE 3.0
allowlist_externals =
{[dev]allowlist_externals}
commands =
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" $(find ./pycode128 ./tests ./docs -name "*.py")
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" --force-dot-license $(find ./pycode128 ./tests ./docs -name "*.json")
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" $(find ./.github \( -name "*.yml" -o -name "*.md" \) )
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" --style python ./.editorconfig ./.gitignore ./. yamllint ./.pre-commit-config.yaml
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" ./docs/Makefile ./docs/make.bat ./pyproject.toml
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" --force-dot-license $(find . -maxdepth 1 -name "*.rst" -o -name "*.md" -o -name "*.lock" -o -name "*.cfg" )
poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" --force-dot-license $(find ./docs -name "*.rst")
poetry run reuse download --all
sed -i '' -e 's/<year>/2023/g;s/<copyright holders>/Gabriele Pongelli/g' LICENSES/MIT.txt
# Windows Call
# poetry run reuse annotate --license=MIT --copyright="Gabriele Pongelli" --year="2023" --force-dot-license $(Get-ChildItem .\tests\*.png)
[testenv:lint]
description = Lint the code
ignore_errors = True
skip_install = true
allowlist_externals =
{[dev]allowlist_externals}
commands_pre =
{[testenv:build]commands}
poetry install
commands =
poetry run flake8 pycode128 tests
poetry run mypy --install-types pycode128 tests build_extension.py
# poetry run yamllint -f colored pycode128
poetry run codespell pycode128 docs/source
poetry run pylint pycode128 build_extension.py
poetry run darglint -v 2 pycode128
poetry run bandit -r pycode128
poetry run reuse lint
[testenv:build]
description = Build package
allowlist_externals =
{[dev]allowlist_externals}
commands_pre =
{[dev]commands}
commands =
poetry build
poetry run twine check dist/*
[testenv:docs]
description = Build docs
skip_install = true
allowlist_externals =
{[dev]allowlist_externals}
commands_pre =
{[dev]commands}
commands =
poetry run sphinx-build -b html docs/source/ docs/build/html
# poetry run sphinx-build -b linkcheck docs/source/ docs/build/html
[testenv:pyvers]
description = Check Python versions
skip_install = true
allowlist_externals =
{[dev]allowlist_externals}
commands_pre =
{[dev]commands}
# sync will remove dependencies not specified in the group
poetry install -v --with pyvers --no-root
commands =
poetry run check-python-versions
poetry run python-active-versions
[testenv:release]
description = Run release task
skip_install = true
allowlist_externals =
{[dev]allowlist_externals}
commands_pre =
{[dev]commands}
commands =
poetry run cz bump --changelog
poetry build
# poetry publish -r ...