Closed turnerm closed 2 years ago
It is possible to migrate most things so that setup.py is no longer needed. The below from HDX Python Utilities runs pytest, isort, black and flake8 from an installed wheel. It outputs coverage information (which can be used by codecov.io). It offers tox -e docs
for creating documentation and tox -e publish
to make a tag in GitHub and upload to Pypi.
[build-system]
requires = [ "setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.black]
line-length = 79
[tool.isort]
profile = "black"
line_length = 79
multi_line_output = 3
[tool.flakehell]
# make output nice
format = "grouped"
max_line_length = 79
# show line of source code in output
show_source = true
# list of plugins and rules for them
[tool.flakehell.plugins]
mccabe = ["+*"]
pycodestyle = ["+*", "-E203", "-E501", "-W503"]
pyflakes = ["+*"]
pylint = ["+*"]
flake8-isort = ["+*"]
flake8-black = ["+*"]
[tool.pytest.ini_options]
site_dirs = "src"
[tool.coverage.paths]
source = ["src/hdx", "*/site-packages/hdx"]
[tool.coverage.report]
omit = [
"*/setup.py",
"*/python?.?/*",
"*/venv/*",
"*/site-packages/*",
"*/tests/*",
"*__init__*"
]
exclude_lines = [
"pragma: no cover", # Have to re-enable the standard pragma
"def __repr__", # Don't complain about missing
"if self.debug", # debug-only code
"raise AssertionError", # Don't complain if tests don't hit
"raise NotImplementedError", # defensive assertion code
"if 0:", # Don't complain if non-runnable code
"if __name__ == .__main__.:" # isn't run
]
[[tool.pydoc-markdown.loaders]]
type = "python"
search_path = ["src"]
packages = ["hdx.utilities"]
[tool.pydoc-markdown.renderer]
type = "markdown"
filename = "apidocs.md"
[tool.pydoc-markdown.renderer.source_linker]
type = "github"
repo = "OCHA-DAP/hdx-python-utilities"
[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py38, lint
[gh-actions]
python =
3: py38, lint
[testenv]
recreate = true
wheel = true
deps =
-r test-requirements.txt
commands =
pytest --cov=hdx --no-cov-on-fail --junitxml=.tox/test-results.xml --cov-report=xml --cov-report=term-missing
[testenv:lint]
wheel_build_env = py38
deps =
flakehell
flake8==3.9.0
flake8-isort
flake8-black
commands =
flakehell lint src tests
[testenv:docs]
wheel_build_env = py38
deps =
pydoc-markdown
commands =
pydoc-markdown
[testenv:publish]
wheel_build_env = py38
passenv = SSH_AUTH_SOCK
deps =
twine
commands =
python -c \"from hdx.utilities.wheel import git_tag_whl; git_tag_whl('{distdir}')\"
twine upload {distdir}/*
"""
Closed by #45
Switch to tox for the tests, migrating as much as possible to
pyproject.toml