-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
98 lines (78 loc) · 2.65 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
include vars.mk
.DEFAULT_GOAL := all
.PHONY: build clean cov default dev docker-deps docs ensure-uv fmt fix install it lint test uninstall version help
all: dev test lint build
build: dev
$(UV) build
clean:
$(MAKE) -C ./docs $@
$(MAKE) -C ./integration $@
rm -rf .coverage .pytest_cache .ruff_cache *.egg-info build coverage.xml dist htmlcov coverage.xml
find src -name "_version.py" -exec rm -rf {} +
find . -name "*.egg-info" -exec rm -rf {} +
find . -name "*.pyc" -exec rm -f {} +
find . -name "__pycache__" -exec rm -rf {} +
find . -type d -empty -delete
cov: dev
$(UV) run coverage report
cov-html: dev
$(UV) run coverage html
open htmlcov/index.html
cov-xml: dev
$(UV) run coverage xml
dev: ensure-uv
$(UV) pip install -e .
docker-deps: ensure-uv
# Sync given the `uv.lock` file
# --frozen : assert that the lock file exists
# --no-install-project : do not install the project itself, but install its dependencies
$(UV) sync --frozen --no-install-project
docs: ensure-uv
$(MAKE) -C ./docs
$(VIRTUAL_ENV):
$(UV) venv $(VIRTUAL_ENV)
ensure-uv:
@if ! command -v $(UV) >/dev/null; then \
$(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \
fi
@# Install virtual environment (before calling `uv pip install ...`)
@$(MAKE) $(VIRTUAL_ENV) 1>/dev/null
@# Be sure recent uv is installed
@$(UV) pip install "uv >= 0.4.27" --quiet
fmt: dev
$(UV) run ruff check --fix
$(UV) run ruff format
install: build
$(UV) pip install dist/*.whl
$(UV_LOCK): dev
$(UV) lock
it: $(UV_LOCK)
$(MAKE) -C ./integration
lint: dev
$(UV) run ruff check
$(UV) run pyright
test: dev
$(UV) run coverage run --source=src -m pytest tests
uninstall: ensure-uv
$(UV) pip uninstall $(PROJECT_NAME)
version:
@$(MAKE) ensure-uv &>/dev/null
@$(UV) run --quiet --with "setuptools_scm" python -m setuptools_scm
help:
@echo "Makefile Targets"
@echo " all Run dev, test, lint, and build"
@echo " build Build the project"
@echo " clean Clean up project artifacts"
@echo " cov Generate a coverage report"
@echo " cov-html Generate an HTML coverage report and open it"
@echo " cov-xml Generate an XML coverage report"
@echo " dev Install the project in editable mode"
@echo " docs Build the documentation"
@echo " ensure-uv Ensure 'uv' is installed"
@echo " fmt Format the code"
@echo " install Install the built project"
@echo " it Run integration tests"
@echo " lint Lint the code"
@echo " test Run unit tests with coverage"
@echo " uninstall Uninstall the project"
@echo " version Display the project version"