-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
139 lines (109 loc) · 3.57 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
128
129
130
131
132
133
134
135
136
137
138
139
PYTHON?=python -X dev
all: help
help: ## Show this help
@echo -e "Specify a command. The choices are:\n"
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[0;36m%-12s\033[m %s\n", $$1, $$2}'
@echo ""
.PHONY: help
# {{{ linting
format: black isort pyproject ## Run all formatting scripts
.PHONY: format
fmt: format
.PHONY: fmt
pyproject: ## Run pyproject-fmt over the configuration
$(PYTHON) -m pyproject_fmt --indent 4 pyproject.toml
@echo -e "\e[1;32mpyproject clean!\e[0m"
.PHONY: pyproject
black: ## Run ruff format over the source code
ruff format src tests examples docs drivers
@echo -e "\e[1;32mruff format clean!\e[0m"
.PHONY: black
isort: ## Run ruff isort fixes over the source code
ruff check --fix --select=I src tests examples docs
ruff check --fix --select=RUF022 src
@echo -e "\e[1;32mruff isort clean!\e[0m"
.PHONY: isort
lint: typos reuse ruff doc8 mypy ## Run linting checks
.PHONY: lint
ruff: ## Run ruff checks over the source code
ruff check src tests examples docs drivers
@echo -e "\e[1;32mruff lint clean!\e[0m"
.PHONY: ruff
mypy: ## Run mypy checks over the source code
$(PYTHON) -m mypy src tests examples drivers
@echo -e "\e[1;32mmypy clean!\e[0m"
.PHONY: mypy
doc8: ## Run doc8 checks over the source code
$(PYTHON) -m doc8 src docs
@echo -e "\e[1;32mdoc8 clean!\e[0m"
.PHONY: doc8
typos: ## Run typos over the source code and documentation
@typos
@echo -e "\e[1;32mtypos clean!\e[0m"
.PHONY: typos
reuse: ## Check REUSE license compliance
$(PYTHON) -m reuse lint
@echo -e "\e[1;32mREUSE compliant!\e[0m"
.PHONY: reuse
# }}}
# {{{ testing
REQUIREMENTS=\
requirements-dev.txt \
requirements.txt
requirements-dev.txt: pyproject.toml
uv pip compile --upgrade --universal --python-version '3.10' \
--extra dev --extra vis \
-o $@ $<
.PHONY: requirements-dev.txt
requirements.txt: pyproject.toml
uv pip compile --upgrade --universal --python-version '3.10' \
-o $@ $<
.PHONY: requirements.txt
pin: $(REQUIREMENTS) ## Pin dependencies versions to requirements.txt
.PHONY: pin
pip-install: ## Install pinned dependencies from requirements.txt
$(PYTHON) -m pip install --upgrade pip hatchling wheel setuptools
$(PYTHON) -m pip install -r requirements-dev.txt -e .
$(PYTHON) -m pip install \
--no-build-isolation \
'git+https://github.com/alexfikl/[email protected]#egg=PyWENO'
.PHONY: pip-install
docs: ## Generate HTML documentation (at docs/_build/html/index.html)
(cd docs; rm -rf _build; make html SPHINXOPTS="-W --keep-going -n")
.PHONY: docs
test: ## Run pytest tests
$(PYTHON) -m pytest -rswx --durations=25 -v -s
.PHONY: test
run-examples: ## Run examples with default options
@for ex in $$(find examples -name "*.py"); do \
echo -e "\x1b[1;32m===> \x1b[97mRunning $${ex}\x1b[0m"; \
$(PYTHON) "$${ex}" || exit $$?; \
sleep 1; \
done
.PHONY: run-examples
run-drivers: ## Run drivers with default options
@for ex in $$(find drivers -name "*.py"); do \
echo -e "\x1b[1;32m===> \x1b[97mRunning $${ex}\x1b[0m"; \
$(PYTHON) "$${ex}" || exit $$?; \
sleep 1; \
done
.PHONY: run-drivers
# }}}
view: ## Open documentation (Linux only)
xdg-open docs/_build/html/index.html
.PHONY: view
ctags: ## Regenerate ctags
ctags --recurse=yes \
--tag-relative=yes \
--exclude=.git \
--exclude=docs \
--python-kinds=-i \
--language-force=python
.PHONY: ctags
clean: ## Remove various build artifacts
rm -rf build dist
rm -rf docs/_build
.PHONY: clean
purge: clean ## Remove various temporary files
rm -rf .ruff_cache .pytest_cache .mypy_cache
.PHONY: purge