Skip to content

Switch to dflit and bump dependencies #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -58,3 +58,12 @@ exclude = '''
| /dist/
)
'''

[tool.coverage.run]
include = [
'src/*',
'mypy_tests/*',
'tests/*',
]
data_file = 'build/coverage-data/coverage'
parallel = true
8 changes: 4 additions & 4 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
71 changes: 36 additions & 35 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 39 additions & 9 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand All @@ -36,44 +66,44 @@ 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
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
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])
Expand Down
10 changes: 6 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down