-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (59 loc) · 1.83 KB
/
Makefile
File metadata and controls
74 lines (59 loc) · 1.83 KB
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
VENV_NAME ?= .venv
ifeq ($(OS),Windows_NT)
USER_PYTHON ?= python
VENV_BIN := $(VENV_NAME)/Scripts
rmrf = rmdir /s /q
rmf = del /q
else
USER_PYTHON ?= python3
VENV_BIN := $(VENV_NAME)/bin
rmrf = rm -rf
rmf = rm -f
endif
VENV_PYTHON := $(VENV_BIN)/python
VENV_UV := $(VENV_BIN)/uv
UV_LOC := $(shell $(USER_PYTHON) -c "import shutil; print(shutil.which('uv') if shutil.which('uv') else '$(VENV_UV)')")
.PHONY: prepare-venv install install-dev test lint format clean docs docs-serve docs-build
.DEFAULT_GOAL := install-dev
prepare-venv: $(VENV_NAME)
$(VENV_NAME):
ifeq ($(UV_LOC),$(VENV_UV))
@echo "Using .venv installed uv: $(UV_LOC)"
$(MAKE) clean && $(USER_PYTHON) -m venv $(VENV_NAME)
$(VENV_PYTHON) -m pip install -U pip
$(VENV_PYTHON) -m pip install uv
else
@echo "Using global uv: $(UV_LOC)"
$(MAKE) clean && $(UV_LOC) venv $(VENV_NAME)
endif
install: prepare-venv
$(UV_LOC) sync
$(UV_LOC) pip install -e .
install-dev: prepare-venv
$(UV_LOC) sync --group dev
$(UV_LOC) pip install -e .
test: install-dev
$(UV_LOC) run pytest -vv -W error
lint: install-dev
$(UV_LOC) run ruff check
$(UV_LOC) run ruff check --select I
$(UV_LOC) run python -m pyright
format: install-dev
$(UV_LOC) run ruff check --select I --fix
$(UV_LOC) run ruff format
clean:
ifeq ($(OS),Windows_NT)
@if exist $(VENV_NAME) $(rmrf) $(VENV_NAME)
@for %%d in (.ruff_cache .pytest_cache transformplan.egg-info site) do @if exist %%d $(rmrf) %%d
@if exist .vscode\*.log $(rmf) .vscode\*.log
@for /d /r %%i in (__pycache__) do @if exist "%%i" $(rmrf) "%%i"
else
$(rmrf) $(VENV_NAME) .ruff_cache .pytest_cache transformplan.egg-info site
$(rmf) .vscode/*.log
find . -type d -name "__pycache__" -exec rm -rf {} +
endif
docs: docs-serve
docs-serve: install-dev
$(UV_LOC) run mkdocs serve
docs-build: install-dev
$(UV_LOC) run mkdocs build