-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
97 lines (81 loc) · 2.3 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
.DEFAULT_GOAL := all
sources = python/pymoors tests
# Thanks to pydantic team for their makefile (pydantic-core) used as reference for pymoors
# using pip install cargo (via maturin via pip) doesn't get the tty handle
# so doesn't render color without some help
export CARGO_TERM_COLOR=$(shell (test -t 0 && echo "always") || echo "auto")
# maturin develop only makes sense inside a virtual env, is otherwise
# more or less equivalent to pip install -e just a little nicer
USE_MATURIN = $(shell [ "$$VIRTUAL_ENV" != "" ] && (which maturin))
.PHONY: .uv ## Check that uv is installed
.uv:
@uv -V || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
.PHONY: .pre-commit ## Check that pre-commit is installed
.pre-commit:
@pre-commit -V || echo 'Please install pre-commit: https://pre-commit.com/'
.PHONY: install
install: .uv .pre-commit
uv pip install -U wheel
uv sync --frozen --group all
uv pip install -v -e .
pre-commit install
.PHONY: rebuild-lockfiles ## Rebuild lockfiles from scratch, updating all dependencies
rebuild-lockfiles: .uv
uv lock --upgrade
.PHONY: build-dev
build-dev:
@rm -f python/pymoors/*.so
ifneq ($(USE_MATURIN),)
uv run maturin develop --uv
else
uv pip install --force-reinstall -v -e . --config-settings=build-args='--profile dev'
endif
.PHONY: build-prod
build-prod:
@rm -f python/pymoors/*.so
ifneq ($(USE_MATURIN),)
uv run maturin develop --uv --release
else
uv pip install -v -e .
endif
.PHONY: format
format:
uv run ruff check --fix $(sources)
uv run ruff format $(sources)
cargo fmt
.PHONY: lint-python
lint-python:
uv run ruff check $(sources)
uv run ruff format --check $(sources)
.PHONY: lint-rust
lint-rust:
cargo fmt --version
cargo fmt --all -- --check
cargo clippy --version
cargo clippy --tests -- -D warnings
.PHONY: lint
lint: lint-python # lint-rust
.PHONY: pyright
pyright:
uv run pyright
.PHONY: test
test:
uv run pytest
.PHONY: all
all: format build-dev lint test
.PHONY: clean
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -rf src/self_schema.py
rm -rf .cache
rm -rf htmlcov
rm -rf .pytest_cache
rm -rf *.egg-info
rm -f .coverage
rm -f .coverage.*
rm -rf build
rm -rf perf.data*
rm -rf python/pymoors/*.so