-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
118 lines (90 loc) · 2.23 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
# convenient makefile
SHELL = /bin/bash
.ONESHELL:
MODULE = CacheToolsUtils
F.md = $(wildcard *.md)
F.pdf = $(F.md:%.md=%.pdf)
# cleanup and environment
.PHONY: clean
clean:
$(RM) -r __pycache__ *.egg-info dist build .mypy_cache .pytest_cache htmlcov .ruff_cache
$(RM) .coverage $(F.pdf)
$(MAKE) -C docs clean
.PHONY: clean.venv
clean.venv: clean
$(RM) -r venv
.PHONY: clean.dev
clean.dev: clean.venv
# venv for local testing
PYTHON = python
PIP = venv/bin/pip
venv:
$(PYTHON) -m venv venv
$(PIP) install --upgrade pip
$(PIP) install -e .[doc,dev,pub,tests]
.PHONY: dev
dev: venv
#
# Tests
#
PYTEST = pytest --log-level=debug --capture=tee-sys
PYTOPT =
.PHONY: check
check: check.mypy check.pyright check.flake8 check.pytest check.coverage check.docs
.PHONY: check.mypy
check.mypy: venv
source venv/bin/activate
mypy $(MODULE).py
.PHONY: check.pyright
check.pyright: venv
source venv/bin/activate
pyright $(MODULE).py
IGNORE = E227,E501
.PHONY: check.flake8
check.flake8: venv
source venv/bin/activate
flake8 --ignore=E129,W504,$(IGNORE) $(MODULE).py
.PHONY: check.ruff
check.ruff: venv
source venv/bin/activate
ruff check --ignore=$(IGNORE) $(MODULE).py
.PHONY: check.black
check.black: venv
source venv/bin/activate
black --check $(MODULE).py
.PHONY: check.pytest
check.pytest: venv
source venv/bin/activate
$(PYTEST) $(PYTOPT) test.py
.PHONY: check.coverage
check.coverage: venv
source venv/bin/activate
coverage run -m $(PYTEST) $(PYTOPT) test.py
# coverage html $(MODULE).py
coverage report --fail-under=100 --precision=1 --show-missing --include=CacheToolsUtils.py
.PHONY: check.docs
check.docs: venv
source venv/bin/activate
pymarkdown -d MD013 scan *.md */*.md
sphinx-lint docs/
.PHONY: docs
docs: venv
source venv/bin/activate
make -C docs html
.PHONY: install
install: $(MODULE).egg-info
type $(PYTHON)
$(MODULE).egg-info: venv
$(PIP) install -e .
# generate source and built distribution
dist: venv
source venv/bin/activate
$(PYTHON) -m build
.PHONY: publish
publish: dist
# provide pypi login/pw or token somewhere…
echo venv/bin/twine upload dist/*
# generate pdf doc
MD2PDF = pandoc -f markdown -t latex -V papersize:a4 -V geometry:hmargin=2.5cm -V geometry:vmargin=3cm
%.pdf: %.md
$(MD2PDF) -o $@ $<