-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (81 loc) · 2.57 KB
/
Makefile
File metadata and controls
101 lines (81 loc) · 2.57 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
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
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 install-tests test test-python-coverage lint format clean docs docs-serve docs-clean
.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 .
install-tests: prepare-venv
$(UV_LOC) sync --group tests
$(UV_LOC) pip install -e .
install-docs: prepare-venv
$(UV_LOC) sync --group docs
$(UV_LOC) pip install -e .
build-dev: install-dev
$(UV_LOC) run maturin develop
test: install-tests
$(UV_LOC) run pytest -vv -W error
cargo test
test-python-coverage: install-tests
$(UV_LOC) run tests/coverage_report.py table
test-python-coverage-non-isolated: install-tests
$(UV_LOC) run coverage run -m pytest -vv -W error
$(UV_LOC) run coverage report -m
docs: install-docs
$(MAKE) -C docs html
docs-serve: install-docs
$(MAKE) -C docs serve VENV_PYTHON=$(CURDIR)/$(VENV_PYTHON)
docs-clean:
$(MAKE) -C docs clean
lint: install-dev
$(UV_LOC) run ruff check
$(UV_LOC) run ruff check --select I
$(UV_LOC) run python -m pyright
cargo clippy --all-targets --all-features
format: install-dev
$(UV_LOC) run ruff check --select I --fix
$(UV_LOC) run ruff format
cargo fmt
cargo clippy --all-features --fix --allow-staged
clean: docs-clean
ifeq ($(OS),Windows_NT)
@if exist $(VENV_NAME) $(rmrf) $(VENV_NAME)
@for %%d in (target dist medmodels.egg-info .ruff_cache .pytest_cache) do @if exist %%d $(rmrf) %%d
@if exist medmodels\*.pyd $(rmf) medmodels\*.pyd
@if exist .vscode\*.log $(rmf) .vscode\*.log
@if exist .coverage $(rmf) .coverage
@for /d /r %%i in (__pycache__) do @if exist "%%i" $(rmrf) "%%i"
else
$(rmrf) $(VENV_NAME) target dist medmodels.egg-info .ruff_cache .pytest_cache
$(rmf) medmodels/*.so
$(rmf) .vscode/*.log
$(rmf) .coverage
find . -type d -name "__pycache__" -exec rm -rf {} +
endif