diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 59e6e3763..cb2f31864 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,7 @@ repos: rev: v1.0.1 hooks: - id: seed-isort-config + args: [--application-directories, src] - repo: https://github.com/pre-commit/mirrors-isort rev: v4.3.4 hooks: diff --git a/setup.py b/setup.py index ea47156b5..9a30a85ac 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,8 @@ def main(): platforms=["unix", "linux", "osx", "cygwin", "win32"], author="holger krekel", author_email="holger@merlinux.eu", - packages=["tox"], + packages=setuptools.find_packages("src"), + package_dir={"": "src"}, entry_points={ "console_scripts": ["tox=tox:cmdline", "tox-quickstart=tox._quickstart:main"] }, @@ -59,7 +60,6 @@ def main(): "pytest-xdist", ], "docs": ["sphinx >= 1.6.3, < 2", "towncrier >= 17.8.0"], - "lint": ["pre-commit == 1.8.2"], "publish": ["devpi", "twine"], }, classifiers=[ diff --git a/tox/__init__.py b/src/tox/__init__.py similarity index 100% rename from tox/__init__.py rename to src/tox/__init__.py diff --git a/tox/__main__.py b/src/tox/__main__.py similarity index 100% rename from tox/__main__.py rename to src/tox/__main__.py diff --git a/tox/_pytestplugin.py b/src/tox/_pytestplugin.py similarity index 100% rename from tox/_pytestplugin.py rename to src/tox/_pytestplugin.py diff --git a/tox/_quickstart.py b/src/tox/_quickstart.py similarity index 100% rename from tox/_quickstart.py rename to src/tox/_quickstart.py diff --git a/tox/_verlib.py b/src/tox/_verlib.py similarity index 100% rename from tox/_verlib.py rename to src/tox/_verlib.py diff --git a/tox/config.py b/src/tox/config.py similarity index 100% rename from tox/config.py rename to src/tox/config.py diff --git a/tox/constants.py b/src/tox/constants.py similarity index 100% rename from tox/constants.py rename to src/tox/constants.py diff --git a/tox/exception.py b/src/tox/exception.py similarity index 100% rename from tox/exception.py rename to src/tox/exception.py diff --git a/tox/hookspecs.py b/src/tox/hookspecs.py similarity index 100% rename from tox/hookspecs.py rename to src/tox/hookspecs.py diff --git a/tox/interpreters.py b/src/tox/interpreters.py similarity index 100% rename from tox/interpreters.py rename to src/tox/interpreters.py diff --git a/tox/result.py b/src/tox/result.py similarity index 100% rename from tox/result.py rename to src/tox/result.py diff --git a/tox/session.py b/src/tox/session.py similarity index 100% rename from tox/session.py rename to src/tox/session.py diff --git a/tox/venv.py b/src/tox/venv.py similarity index 100% rename from tox/venv.py rename to src/tox/venv.py diff --git a/tox.ini b/tox.ini index 46a892b81..35807d428 100644 --- a/tox.ini +++ b/tox.ini @@ -12,20 +12,25 @@ skip_missing_interpreters = true [testenv] description = run the tests with pytest under {basepython} -setenv = COVERAGE_FILE={toxworkdir}/.coverage.{envname} +setenv = PIP_DISABLE_VERSION_CHECK = 1 + COVERAGE_FILE = {toxworkdir}/.coverage.{envname} passenv = http_proxy https_proxy no_proxy SSL_CERT_FILE TOXENV CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_* +deps = extras = testing -commands = pytest {posargs:--cov-config="{toxinidir}/tox.ini" --cov="{envsitepackagesdir}/tox" --timeout=180 tests} +changedir = {toxinidir}/tests +commands = pytest {posargs:--cov="{envsitepackagesdir}/tox" --cov-config="{toxinidir}/tox.ini" --timeout=180 .} [testenv:docs] description = invoke sphinx-build to build the HTML docs and check that all links are valid whitelist_externals = sphinx-build basepython = python3.6 extras = docs +changedir = {toxinidir} commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -bhtml [testenv:fix-lint] +description = format the code base to adhere to our styles, and complain about what we cannot do automatically basepython = python3.6 passenv = {[testenv]passenv} HOMEPATH @@ -33,26 +38,35 @@ passenv = {[testenv]passenv} # `error setting certificate verify locations` error PROGRAMDATA extras = lint -description = run static analysis and style check using flake8 +deps = pre-commit == 1.10.1 +skip_install = True +changedir = {toxinidir} commands = pre-commit run --all-files --show-diff-on-failure python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")' [testenv:coverage] -description = combine coverage data and create reports -deps = coverage +description = [run locally after tests]: combine coverage data and create report; + generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var) +deps = {[testenv]deps} + coverage >= 4.4.1, < 5 + diff_cover skip_install = True -changedir = {toxworkdir} -setenv = COVERAGE_FILE=.coverage +passenv = {[testenv]passenv} + DIFF_AGAINST +setenv = COVERAGE_FILE={toxworkdir}/.coverage +changedir = {toxinidir} commands = coverage erase coverage combine - coverage report --rcfile="{toxinidir}/tox.ini" - coverage xml + coverage report -m + coverage xml -o {toxworkdir}/coverage.xml + diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml [testenv:codecov] description = [only run on CI]: upload coverage data to codecov (depends on coverage running first) deps = codecov skip_install = True +changedir = {toxinidir} commands = codecov --file "{toxworkdir}/coverage.xml" [testenv:exit_code] @@ -61,6 +75,7 @@ commands = codecov --file "{toxworkdir}/coverage.xml" basepython = python3.6 description = commands with several exit codes skip_install = True +changedir = {toxinidir} commands = python3.6 -c "import sys; sys.exit(139)" [testenv:pra] @@ -68,6 +83,7 @@ platform = linux passenv = * description = "personal release assistant" - see HOWTORELEASE.rst extras = publish, docs +changedir = {toxinidir} commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -blinkcheck "{toxinidir}/tasks/pra.sh" {posargs} @@ -81,6 +97,7 @@ extras = testing, docs # required to make looponfail reload on every source code change usedevelop = True basepython = python3.6 +changedir = {toxinidir} commands = python -m pip list --format=columns python -c 'import sys; print(sys.executable)' @@ -90,7 +107,7 @@ max-line-length = 99 ignore = E203, W503 [coverage:run] -omit = tox/__main__.py +branch = true [coverage:report] skip_covered = True @@ -98,13 +115,13 @@ show_missing = True exclude_lines = if __name__ == ["']__main__["']: [coverage:paths] -source = tox - {toxworkdir}/*/lib/python*/site-packages/tox - {toxworkdir}/*/Lib/site-packages/tox - {toxworkdir}/pypy*/site-packages/tox +source = src/tox + .tox/*/lib/python*/site-packages/tox + .tox/*/Lib/site-packages/tox + .tox/pypy*/site-packages/tox [pytest] -addopts = -rsxX -vvv --showlocals +addopts = -rsxX --showlocals rsyncdirs = tests tox looponfailroots = tox tests norecursedirs = .hg .tox