From c91e5660ca58d4169b674db350a5fd9bd0adb14b Mon Sep 17 00:00:00 2001 From: David Fritzsche Date: Sun, 29 Mar 2020 10:06:06 +0200 Subject: [PATCH] Switch to dflit and bump dependencies --- .github/workflows/pythonpackage.yml | 9 ++-- pyproject.toml | 11 ++++- requirements.in | 8 ++-- requirements.txt | 71 +++++++++++++++-------------- tasks.py | 48 +++++++++++++++---- tox.ini | 10 ++-- 6 files changed, 101 insertions(+), 56 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index b701ecf..3539d35 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -22,10 +22,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -c requirements.txt tox - - name: Run tox + python -m pip install -c requirements.txt invoke tox + - name: Run tox for pytest 5.3.x + env: + TOX_PARALLEL_NO_SPINNER: "1" run: | - tox -e py-mypy0750,py-mypy0761 + inv mkdir build/coverage-data + inv tox -e "py-*" lint: runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index 6a5c557..5d53705 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: CC0-1.0 [build-system] -requires = ["flit_core >=2,<3"] +requires = ["dflit_core >=2,<3"] build-backend = "flit_core.buildapi" [tool.flit.metadata] @@ -58,3 +58,12 @@ exclude = ''' | /dist/ ) ''' + +[tool.coverage.run] +include = [ + 'src/*', + 'mypy_tests/*', + 'tests/*', +] +data_file = 'build/coverage-data/coverage' +parallel = true diff --git a/requirements.in b/requirements.in index 99957d6..0377b6a 100644 --- a/requirements.in +++ b/requirements.in @@ -2,17 +2,17 @@ # SPDX-License-Identifier: CC0-1.0 black==19.10b0 bump2version +coverage[toml] +dflit flake8-black flake8-isort -flit -flit_core>=2,<3 fsfe-reuse invoke -mypy==0.761 +mypy==0.770 pip-tools pip>=19.3 pytest-cov -pytest~=5.3 +pytest~=5.3.5 setuptools>=43 tox-pyenv tox>=3.14.3 diff --git a/requirements.txt b/requirements.txt index 1e005fd..eedbc3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,61 +4,62 @@ # # pip-compile --allow-unsafe --no-index --upgrade # -appdirs==1.4.3 # via black +appdirs==1.4.3 # via black, virtualenv attrs==19.3.0 # via black, pytest binaryornot==0.4.4 # via reuse -black==19.10b0 +black==19.10b0 # via -r requirements.in, flake8-black boolean.py==3.7 # via license-expression, reuse -bump2version==0.5.11 +bump2version==1.0.0 # via -r requirements.in certifi==2019.11.28 # via requests chardet==3.0.4 # via binaryornot, python-debian, requests -click==7.0 # via black, pip-tools -coverage==5.0.3 # via pytest-cov -docutils==0.16 # via flit +click==7.1.1 # via black, pip-tools +coverage[toml]==5.0.4 # via -r requirements.in, pytest-cov +dflit-core==2.2.0.1 # via dflit +dflit==2.2.0.1 # via -r requirements.in +distlib==0.3.0 # via virtualenv +docutils==0.16 # via dflit entrypoints==0.3 # via flake8 -filelock==3.0.12 # via tox -flake8-black==0.1.1 -flake8-isort==2.8.0 +filelock==3.0.12 # via tox, virtualenv +flake8-black==0.1.1 # via -r requirements.in +flake8-isort==2.9.1 # via -r requirements.in flake8==3.7.9 # via flake8-black, flake8-isort -flit-core==2.2.0 -flit==2.2.0 -fsfe-reuse==1.0.0 -idna==2.8 # via requests -invoke==1.4.0 +fsfe-reuse==1.0.0 # via -r requirements.in +idna==2.9 # via requests +invoke==1.4.1 # via -r requirements.in isort[pyproject]==4.3.21 # via flake8-isort -jinja2==2.10.3 # via reuse +jinja2==2.11.1 # via reuse license-expression==1.2 # via reuse markupsafe==1.1.1 # via jinja2 mccabe==0.6.1 # via flake8 -more-itertools==8.1.0 # via pytest +more-itertools==8.2.0 # via pytest mypy-extensions==0.4.3 # via mypy -mypy==0.761 -packaging==20.0 # via pytest, tox +mypy==0.770 # via -r requirements.in +packaging==20.3 # via pytest, tox pathspec==0.7.0 # via black -pip-tools==4.3.0 +pip-tools==4.5.1 # via -r requirements.in pluggy==0.13.1 # via pytest, tox py==1.8.1 # via pytest, tox pycodestyle==2.5.0 # via flake8 pyflakes==2.1.1 # via flake8 pyparsing==2.4.6 # via packaging -pytest-cov==2.8.1 -pytest==5.3.2 +pytest-cov==2.8.1 # via -r requirements.in +pytest==5.3.5 # via -r requirements.in, pytest-cov python-debian==0.1.36 # via reuse -pytoml==0.1.21 # via flit, flit-core -regex==2020.1.8 # via black -requests==2.22.0 # via flit, reuse -reuse==0.7.0 # via fsfe-reuse -six==1.14.0 # via packaging, pip-tools, python-debian, tox -testfixtures==6.10.3 # via flake8-isort -toml==0.10.0 # via black, isort, tox -tox-pyenv==1.1.0 -tox==3.14.3 +pytoml==0.1.21 # via dflit, dflit-core +regex==2020.2.20 # via black +requests==2.23.0 # via dflit, reuse +reuse==0.8.1 # via fsfe-reuse +six==1.14.0 # via packaging, pip-tools, python-debian, tox, virtualenv +testfixtures==6.14.0 # via flake8-isort +toml==0.10.0 # via black, coverage, isort, tox +tox-pyenv==1.1.0 # via -r requirements.in +tox==3.14.6 # via -r requirements.in, tox-pyenv typed-ast==1.4.1 # via black, mypy typing-extensions==3.7.4.1 # via mypy -urllib3==1.25.7 # via requests -virtualenv==16.7.9 # via tox -wcwidth==0.1.8 # via pytest +urllib3==1.25.8 # via requests +virtualenv==20.0.15 # via tox +wcwidth==0.1.9 # via pytest # The following packages are considered to be unsafe in a requirements file: -pip==19.3.1 -setuptools==45.0.0 +pip==20.0.2 # via -r requirements.in +setuptools==46.1.3 # via -r requirements.in diff --git a/tasks.py b/tasks.py index 2beec1d..d04206d 100644 --- a/tasks.py +++ b/tasks.py @@ -2,10 +2,19 @@ # SPDX-License-Identifier: CC0-1.0 import os +import sys from invoke import task +MAYBE_PTY = sys.platform != "win32" + + +@task +def mkdir(ctx, dirname): + os.makedirs(dirname, exist_ok=True) + + @task def pth(ctx): import distutils.sysconfig @@ -16,14 +25,35 @@ def pth(ctx): print(os.path.abspath("src"), file=f) +@task(pre=[pth]) +def tox(ctx, parallel="auto", e="ALL"): + import fnmatch + import itertools + + env_patterns = list(filter(None, e.split(","))) + result = ctx.run("tox --listenvs-all", hide=True, pty=False) + all_envs = result.stdout.splitlines() + + if any(pat == "ALL" for pat in env_patterns): + envs = set(all_envs) + else: + envs = set( + itertools.chain.from_iterable( + fnmatch.filter(all_envs, pat) for pat in env_patterns + ) + ) + envlist = ",".join(sorted(envs)) + ctx.run(f"tox --parallel={parallel} -e {envlist}", echo=True, pty=MAYBE_PTY) + + @task def mypy(ctx): - ctx.run("mypy src tests", echo=True, pty=True) + ctx.run("mypy src tests", echo=True, pty=MAYBE_PTY) @task def flake8(ctx): - ctx.run("flake8", echo=True, pty=True) + ctx.run("flake8", echo=True, pty=MAYBE_PTY) @task(pre=[pth]) @@ -36,22 +66,22 @@ def pytest(ctx): "--cov-report=html:build/cov_html", "--cov-report=term:skip-covered", ] - ctx.run(" ".join(cmd), echo=True, pty=True) + ctx.run(" ".join(cmd), echo=True, pty=MAYBE_PTY) @task def black(ctx): - ctx.run("black --check --diff .", echo=True, pty=True) + ctx.run("black --check --diff .", echo=True, pty=MAYBE_PTY) @task def reuse_lint(ctx): - ctx.run("reuse lint", echo=True, pty=True) + ctx.run("reuse lint", echo=True, pty=MAYBE_PTY) @task def black_reformat(ctx): - ctx.run("black .", echo=True, pty=True) + ctx.run("black .", echo=True, pty=MAYBE_PTY) @task @@ -59,7 +89,7 @@ def lock_requirements(ctx, upgrade=False): cmd = "pip-compile --allow-unsafe --no-index" if upgrade: cmd += " --upgrade" - ctx.run(cmd, env={"CUSTOM_COMPILE_COMMAND": cmd}, echo=True, pty=True) + ctx.run(cmd, env={"CUSTOM_COMPILE_COMMAND": cmd}, echo=True, pty=MAYBE_PTY) @task @@ -67,13 +97,13 @@ def build(ctx): result = ctx.run("git show -s --format=%ct HEAD") timestamp = result.stdout.strip() cmd = "flit build" - ctx.run(cmd, env={"SOURCE_DATE_EPOCH": timestamp}, echo=True, pty=True) + ctx.run(cmd, env={"SOURCE_DATE_EPOCH": timestamp}, echo=True, pty=MAYBE_PTY) @task def publish(ctx, repository="testpypi"): cmd = "flit publish --repository=%s" % (repository,) - ctx.run(cmd, echo=True, pty=True) + ctx.run(cmd, echo=True, pty=MAYBE_PTY) @task(pre=[mypy, pytest, flake8]) diff --git a/tox.ini b/tox.ini index 405cbe1..bf82bd4 100644 --- a/tox.ini +++ b/tox.ini @@ -3,18 +3,20 @@ [tox] isolated_build = True envlist = - {py,py36,py37,py38}-mypy{0750,0761} + {py,py36,py37,py38}-pytest53-mypy{0750,0761,0770} linting [testenv] deps = - pytest~=5.3 - pytest-cov + coverage[toml] dataclasses;python_version<"3.7" + pytest53: pytest~=5.3.5 + pytest-cov mypy0750: mypy==0.750 mypy0761: mypy==0.761 + mypy0770: mypy==0.770 commands = - pytest --cov=pytest_mypy_testing + coverage run -m pytest [testenv:linting] deps =