-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtasks.py
79 lines (59 loc) · 1.66 KB
/
tasks.py
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
"""Invoke task file"""
from invoke import task
from os import environ
import toml
PYPROJECT_CONFIG = toml.load("pyproject.toml")
VENV = environ.get("VIRTUAL_ENV")
@task
def black(c, overwrite=False):
"""Run black PEP8 formatter
Args:
overwrite (bool): Force overwriting files. If False, show diffs instead.
"""
if overwrite:
c.run("black .")
else:
c.run("black --diff --check .")
@task
def pylint(c):
"""Run pylint linter"""
c.run(f"pylint {PYPROJECT_CONFIG['project']['name']}")
@task
def test(c, verbose=False):
"""Run pytest tester"""
opts = []
if verbose:
opts.append("-vv")
c.run("pytest " + " ".join(opts))
@task(black, pylint, test)
def linters(c):
"""Run all linters"""
pass
@task
def mkdocs(c, all=False):
"""Compile docs"""
opts = []
if all:
opts.append("-a")
c.run("sphinx-build docs-source docs " + " ".join(opts))
@task
def clean(c, force=False):
"""Cleanup working directory
Cleanup will skip `private` and `.idea` directories to preserve developer data.
Without `--force` we print out what to be done but no deletion will happen!
"""
if force:
c.run("git clean -d -x -e private -e .idea -f")
else:
c.run("git clean -d -x -e private -e .idea -n")
@task(linters)
def build(c):
"""Build wheel and source packages as preparation for pypi deployment
Consider doing `clean` before running this!
"""
c.run("flit build")
@task(linters)
def publish(c):
"""Build and publish on PyPi"""
print("\n", " PUBLISH ".center(80, "-"), "\nPlease run this command:\n")
print("flit publish --format wheel")