-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
43 lines (34 loc) · 1017 Bytes
/
Copy pathtasks.py
File metadata and controls
43 lines (34 loc) · 1017 Bytes
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
from invoke import task
import shutil
import os
from pathlib import Path
@task
def clean(c):
shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist", ignore_errors=True)
for item in Path(".").glob("*.egg-info"):
shutil.rmtree(item, ignore_errors=True)
for pycache in Path(".").rglob("__pycache__"):
shutil.rmtree(pycache, ignore_errors=True)
for pyc in Path(".").rglob("*.pyc"):
pyc.unlink()
@task
def install(c):
c.run('pip install -e ".[dev]"', pty=True)
@task(pre=[install])
def test(c):
c.run("pytest tests/ --cov=src --cov-report=term-missing", pty=True)
@task
def lint(c):
c.run("black .", pty=True)
c.run("isort .", pty=True)
c.run("flake8 .", pty=True)
@task(pre=[clean])
def build(c):
c.run("python -m build", pty=True)
@task(pre=[build])
def publish_test(c):
c.run("python -m twine upload --repository testpypi dist/*", pty=True)
@task(pre=[build])
def publish(c):
c.run("python -m twine upload dist/*", pty=True)