-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (87 loc) · 2.32 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
# convenient makefile
SHELL = /bin/bash
.ONESHELL:
MODULE = FlaskTester
VENV = venv
F.md = $(wildcard *.md)
F.pdf = $(F.md:%.md=%.pdf)
# PYTHON = /snap/bin/pypy3
# PYTHON = python3
PYTHON = python
.PHONY: check.mypy
check.mypy: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
mypy --implicit-optional --check-untyped-defs $(MODULE).py
.PHONY: check.pyright
check.pyright: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
pyright $(MODULE).py
# E127,W504
.PHONY: check.ruff
check.ruff: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
ruff check --ignore=E227,E402,E501,E721,F401,F811 $(MODULE).py
.PHONY: check.pytest
check.pytest: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
$(MAKE) -C tests check
.PHONY: check.coverage
check.coverage: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
$(MAKE) -C tests check.coverage
# MD013: line length
.PHONY: check.docs
check.docs:
[ "$(VENV)" ] && source $(VENV)/bin/activate
pymarkdown -d MD013 scan *.md
sphinx-lint docs/
.PHONY: check
check: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
type $(PYTHON)
$(MAKE) check.mypy
$(MAKE) check.pyright
$(MAKE) check.docs
$(MAKE) check.ruff
$(MAKE) check.pytest && \
$(MAKE) check.coverage
.PHONY: docs
docs: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
$(MAKE) -C docs html
find docs/_build -type d -print0 | xargs -0 chmod a+rx
find docs/_build -type f -print0 | xargs -0 chmod a+r
ln -s docs/_build/html _site
.PHONY: clean
clean:
$(RM) -r __pycache__ */__pycache__ dist build .mypy_cache .pytest_cache .ruff_cache _site
$(RM) $(F.pdf)
$(MAKE) -C tests clean
$(MAKE) -C docs clean
.PHONY: clean.venv
clean.venv: clean
$(RM) -r venv *.egg-info
.PHONY: venv.update
venv.update:
[ "$(VENV)" ] && source $(VENV)/bin/activate
pip install -U pip
pip install -e .[dev,doc]
# for local testing
venv:
$(PYTHON) -m venv venv
$(MAKE) venv.update
$(MODULE).egg-info: venv
[ "$(VENV)" ] && source $(VENV)/bin/activate
pip install -e .
# generate source and built distribution
dist: venv
[ "$(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 $@ $<