-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (94 loc) · 3.34 KB
/
Makefile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
PYTHON = python3
override src = src
override tests = tests
override venv = .venv
override installed = $(venv)/.installed
.PHONY: setup
setup: $(installed) vscode
.PHONY: format
format: black isort
.PHONY: check
check: lint coverage
.PHONY: lint
lint: black-check isort-check flake8
.PHONY: black
black: $(venv)/bin/black
$(venv)/bin/black -q $(src) $(tests) setup.py
.PHONY: isort
isort: $(venv)/bin/isort
$(venv)/bin/isort $(src) $(tests) setup.py
.PHONY: black-check
black-check: $(venv)/bin/black
$(venv)/bin/black -q --check $(src) $(tests) setup.py
.PHONY: isort-check
isort-check: $(venv)/bin/isort
$(venv)/bin/isort -c $(src) $(tests) setup.py
.PHONY: flake8
flake8: $(venv)/bin/flake8
$(venv)/bin/flake8 $(src) $(tests) setup.py
.PHONY: test
test: $(venv)/bin/pytest $(installed)
$(venv)/bin/pytest
.PHONY: coverage
coverage: $(venv)/bin/pytest $(installed)
$(venv)/bin/pytest --cov --cov-report=term --cov-report=xml
.PHONY: build
build: $(venv)/bin/pyproject-build
$(venv)/bin/pyproject-build
.PHONY: vscode
vscode: .vscode/settings.json
# clean tasks -----------------------------------------------------------------
.PHONY: clean
clean: $(shell grep -o '^clean-[^:]*' Makefile)
.PHONY: clean-venv
clean-venv:
rm -rf $(venv)
.PHONY: clean-pyc
clean-pyc:
find . -type f -name '*.py[co]' -delete
find . -type d -name __pycache__ -delete
.PHONY: clean-test
clean-test:
rm -rf .pytest_cache
.PHONY: clean-coverage
clean-coverage: clean-test
rm -rf .coverage coverage.xml
.PHONY: clean-build
clean-build:
rm -rf dist src/*.egg-info
.PHONY: clean-vscode
clean-vscode:
rm -rf .vscode
# venv creation ---------------------------------------------------------------
$(venv)/bin/python:
$(PYTHON) -m venv $(venv) --clear --without-pip
$(venv)/bin/pip3: $(venv)/bin/python
$(venv)/bin/python -m ensurepip
$(venv)/bin/pip3 install -U pip
# project installation --------------------------------------------------------
$(venv)/.installed: $(venv)/bin/pip3
$(venv)/bin/pip3 install -e . && touch $@
# builder installation --------------------------------------------------------
$(venv)/bin/pyproject-build: $(venv)/bin/pip3
$(venv)/bin/pip3 install -I build==1.0.3
# checker installation --------------------------------------------------------
$(venv)/bin/black: $(venv)/bin/pip3
$(venv)/bin/pip3 install -I black==23.9.1
$(venv)/bin/isort: $(venv)/bin/pip3
$(venv)/bin/pip3 install -I isort==5.12.0
$(venv)/bin/flake8: $(venv)/bin/pip3
$(venv)/bin/pip3 install -I flake8==6.1.0
$(venv)/bin/pip3 install -I flake8-black==0.3.6
$(venv)/bin/pip3 install -I flake8-tidy-imports==4.10.0
$(venv)/bin/pytest: $(venv)/bin/pip3
$(venv)/bin/pip3 install -I pytest==7.4.2
$(venv)/bin/pip3 install -I pytest-cov==4.1.0
# editor setting generation ---------------------------------------------------
.vscode/settings.json:
mkdir -p .vscode
echo '{' > .vscode/settings.json
echo ' "coverage-gutters.showLineCoverage": true,' >> .vscode/settings.json
echo ' "python.linting.flake8Enabled": true,' >> .vscode/settings.json
echo ' "python.testing.pytestEnabled": true,' >> .vscode/settings.json
echo ' "python.defaultInterpreterPath": "$(venv)/bin/python",' >> .vscode/settings.json
echo '}' >> .vscode/settings.json