-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (64 loc) · 1.95 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
SHELL := /bin/bash
.SHELLFLAGS = -ec
.DEFAULT_GOAL = help
.PHONY = help clean format test install-deps venv
DEV_VENV := .dev_venv
DEV_DEPS_CACHE := $(DEV_VENV)/dev-deps.cache
DOC_VENV := .doc_venv
DOC_DEPS_CACHE := $(DOC_VENV)/doc-deps.cache
help:
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'
$(DEV_DEPS_CACHE): pyproject.toml
@echo "Installing development dependencies..."
@test -d .venv || python3 -m venv $(DEV_VENV)
@( \
source ./$(DEV_VENV)/bin/activate; \
pip install --editable .[dev]; \
touch $(DEV_DEPS_CACHE); \
)
install-dev-deps: $(DEV_DEPS_CACHE) ## Install development dependencies
@echo "Development deps have been installed..."
$(DOC_DEPS_CACHE): pyproject.toml
@echo "Installing documenation dependencies..."
@test -d .venv || python3 -m venv $(DOC_VENV)
@( \
source ./$(DOC_VENV)/bin/activate; \
pip install --editable .[doc]; \
touch $(DOC_DEPS_CACHE); \
)
install-doc-deps: $(DOC_DEPS_CACHE) ## Install documentation dependencies
@echo "Documentation deps have been installed..."
format: install-dev-deps ## Format the project
@( \
source ./$(DEV_VENV)/bin/activate; \
ruff format; \
ruff check --fix; \
)
validate: install-dev-deps ## Validate the projects formatting
@( \
source ./$(DEV_VENV)/bin/activate; \
ruff format --check; \
ruff check; \
python3 -m mypy ./src/; \
)
test: install-dev-deps ## Run unit tests
@( \
source ./$(DEV_VENV)/bin/activate; \
pytest --cov=./src/ $(ARGS); \
)
doc-serve: install-doc-deps ## Serve the documentation locally
@( \
source ./$(DOC_VENV)/bin/activate; \
sphinx-autobuild -M html docs docs/_build; \
)
clean: ## Clean generated project files
@rm -f .coverage
@rm -rf ./.ruff_cache
@rm -rf ./.pytest_cache
@rm -rf ./$(DEV_VENV)
@rm -rf ./$(DOC_VENV)
@rm -rf ./.tox
@rm -rf ./dist
@rm -rf ./.mypy_cache
@rm -rf ./docs/_build
@find . -type d -name "__pycache__" -exec rm -rf {} +