File: Makefile

package info (click to toggle)
python-tatsu 5.17.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,516 kB
  • sloc: python: 13,185; makefile: 127
file content (182 lines) | stat: -rw-r--r-- 3,710 bytes parent folder | download
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Copyright (c) 2017-2026 Juancarlo Añez (apalala@gmail.com)
# SPDX-License-Identifier: BSD-4-Clause

ifeq ($(OS), Windows_NT)
    PLATFORM := Windows
else
    PLATFORM := $(shell uname -s)
endif


PYTHON := 3.14


all:  test documentation examples build requirements


test:  lint pytest

test_plus: clean_plus test


__version__:
	@- echo "->" $$(uv run python3 --version) $$(uv run python3 -m tatsu --version)


__line__:
	@- uvx python3 -c "import shutil; print('━' * shutil.get_terminal_size().columns)"


__tests_init__: __line__ __version__
	@- uv sync -q --python $(PYTHON) --group test


pytest: __tests_init__ clean
	@- echo "-> $@"
	@- mkdir -p ./tmp
	@- touch ./tmp/__init__.py
	@- uv run -q --python $(PYTHON) pytest --quiet tests/


documentation: sphinx_make


docs: documentation


doc: documentation


sphinx_make:
	@- uv sync -q --python $(PYTHON) --group doc
	@  echo "-> docs"
	@- cd docs; uv run -q --python $(PYTHON) make -s html > /dev/null


examples: clean g2e_test calc_test


g2e_test:
	@- echo "-> examples/g2e"
	@- cd examples/g2e && uv run -q --python $(PYTHON) make -s clean test > /dev/null
	@- cd examples/g2e && uv run -q --python $(PYTHON) make -s clean > /dev/null


calc_test:
	@- echo "-> examples/calc"
	@- cd examples/calc && uv run -q --python $(PYTHON) make -s clean test > /dev/null


lint: ruff ty pyright


ruff: __tests_init__ clean
	@- echo "-> $@"
	@- uv run -q --python $(PYTHON) ruff check -q --preview --fix tatsu tests examples


mypy: __tests_init__ clean
	@- echo "-> $@"
	@- uv run -q --python $(PYTHON) mypy tatsu tests examples \
		--install-types \
		--exclude dist \
		--exclude parsers \
		--exclude backup

pyright: basedpyright


basedpyright: __tests_init__ clean
	@- echo "-> $@"
	@- uv run -q --python $(PYTHON) basedpyright tatsu tests examples


ty: __tests_init__ clean
	@- 	echo "-> $@"
	@- 	unbuffer uv run -q --python $(PYTHON) ty check tatsu tests examples | (! rg --color=always -v "All checks passed!")


clean:
	@- find tatsu tests examples -name "__pycache__" | xargs /bin/rm -rf
	@- /bin/rm -rf tatsu.egg-info dist tmp build .tox


clean_plus: clean
	@- /bin/rm -rf .cache .pytest_cache .ruff_cache .mypy_cache


checks: matrix

MATRIX := test
matrix: matrix_run __line__
matrix_run: py312 py313 py314 py315

py312: PYTHON := 3.12
py312:
	@- uv run -q --python $(PYTHON) make PYTHON=$(PYTHON) $(MATRIX)

py313: PYTHON := 3.13
py313:
	@- uv run -q --python $(PYTHON) make PYTHON=$(PYTHON) $(MATRIX)

py314: PYTHON := 3.14
py314:
	@- uv run -q --python $(PYTHON) make PYTHON=$(PYTHON) $(MATRIX)

py315: PYTHON := 3.15
py315:
	@- uv run -q --python $(PYTHON) make PYTHON=$(PYTHON) $(MATRIX)


build: clean
	@- echo "-> $@"
	@- uvx hatch build


requirements: \
	uv.lock \
	requirements.txt \
	requirements-dev.txt \
	requirements-test.txt \
	requirements-doc.txt


requirements.txt: uv.lock
	@echo "->" $@
	@- uv export -q --format requirements-txt --no-hashes \
		--no-group dev \
		-o $@

requirements-dev.txt: uv.lock
	@echo "->" $@
	@- uv export -q --format requirements-txt --no-hashes \
		--dev \
		-o $@

requirements-test.txt: uv.lock
	@echo "->" $@
	@- uv export -q --format requirements-txt --no-hashes \
		--group test --no-group dev \
		-o $@

requirements-doc.txt: uv.lock
	@echo "->" $@
	@- uv export -q --format requirements-txt --no-hashes \
		--group doc --no-group dev \
		-o $@


need_gh:
	@- uv tool install -q gh
	@- gh --version | head -n 1


test_publish: need_gh build
	gh workflow run test_publish.yml
	@- gh run list --workflow="test_publish.yml"


publish: need_gh matrix build
	# CAVEAT: Trusted Publishers are now enabled in pypi.org
	gh workflow run publish.yml
	@- gh run list --workflow="publish.yml"