-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (65 loc) · 2.15 KB
/
Makefile
File metadata and controls
84 lines (65 loc) · 2.15 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
# BareTensor convenience commands.
#
# Usage:
# make <target>
#
# Notes:
# - Most Python commands are run via `uv run`.
# - Use `PYTHONPATH=src` so `import bt` finds the `src/` layout package.
# - The native extension is built into `src/bt/` so imports work without install.
SHELL := /bin/bash
.DEFAULT_GOAL := help
UV ?= uv
CMAKE ?= cmake
PYTHONPATH ?= src
BUILD_DIR ?= build
.PHONY: help
help: ## Show available targets
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z0-9_.-]+:.*##/ {printf "%-18s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: bootstrap
bootstrap: ## Install deps + venv + build + run tests (macOS: uses Homebrew)
./scripts/bootstrap.sh
.PHONY: sync
sync: ## Install/update dev tools (ruff/ty/nanobind) in .venv
$(UV) sync --dev
.PHONY: configure
configure: ## Configure CMake (preset: dev)
$(CMAKE) --preset dev
.PHONY: build
build: ## Build native extension (preset: dev)
$(CMAKE) --build --preset dev
.PHONY: rebuild
rebuild: ## Clean build dir, then configure + build
rm -rf "$(BUILD_DIR)"
$(CMAKE) --preset dev
$(CMAKE) --build --preset dev
.PHONY: run
run: ## Run the example script
PYTHONPATH="$(PYTHONPATH)" $(UV) run python examples/example.py
.PHONY: repl
repl: ## Start an interactive Python REPL with bt importable
PYTHONPATH="$(PYTHONPATH)" $(UV) run python
.PHONY: test
test: ## Run unit tests (unittest discovery)
PYTHONPATH="$(PYTHONPATH)" $(UV) run python -m unittest discover -v -s tests -p "test_*.py"
.PHONY: fmt
fmt: ## Format Python (ruff format)
PYTHONPATH="$(PYTHONPATH)" $(UV) run ruff format src tests examples
.PHONY: lint
lint: ## Lint Python (ruff check)
PYTHONPATH="$(PYTHONPATH)" $(UV) run ruff check src tests examples
.PHONY: typecheck
typecheck: ## Typecheck Python (ty)
PYTHONPATH="$(PYTHONPATH)" $(UV) run ty check
.PHONY: check
check: lint typecheck test ## Run lint + typecheck + tests
.PHONY: stub
stub: ## Generate/update nanobind stubs via CMake
$(CMAKE) --build --preset dev --target bt_stub
.PHONY: clean
clean: ## Remove CMake build directory
rm -rf "$(BUILD_DIR)"
.PHONY: distclean
distclean: clean ## Remove build dir + venv + compiled extension
rm -rf .venv
rm -f src/bt/_C*.so src/bt/_C*.dylib src/bt/_C*.pyd