forked from copier-org/copier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevtasks.py
53 lines (49 loc) · 1.31 KB
/
devtasks.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
import os
import shutil
from pathlib import Path
from subprocess import check_call
def clean():
"""
Clean build, test or other process artefacrts from the project workspace
"""
build_artefacts = (
"build/",
"dist/",
"*.egg-info",
"pip-wheel-metadata",
)
python_artefacts = (
".pytest_cache",
"htmlcov",
".coverage",
"**/__pycache__",
"**/*.pyc",
"**/*.pyo",
)
project_dir = Path(".").resolve()
for pattern in build_artefacts + python_artefacts:
for matching_path in project_dir.glob(pattern):
print(f"Deleting {matching_path}")
if matching_path.is_dir():
shutil.rmtree(matching_path)
else:
matching_path.unlink()
def dev_setup():
"""Setup a development environment."""
# Gitpod sets PIP_USER=yes, which breaks poetry
env = dict(os.environ, PIP_USER="no")
check_call(["poetry", "install", "--extras", "docs"], env=env)
check_call(
[
"poetry",
"run",
"pre-commit",
"install",
"-t",
"pre-commit",
"-t",
"commit-msg",
],
env=env,
)
check_call(["poetry", "run", "pre-commit", "install-hooks"], env=env)