-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (104 loc) · 4.43 KB
/
Makefile
File metadata and controls
122 lines (104 loc) · 4.43 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
SHELL := /bin/bash
.PHONY: help
help: ## Displays help information about available make commands
@if command -v uv &> /dev/null; then \
uv run --no-project python -c "import re; \
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open('$(MAKEFILE_LIST)').read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]"; \
else \
echo "Available commands include: help, compile, test..."; \
echo "Run 'make install-uv' to install uv."; \
echo "Then run 'make help' again to see docs on available commands."; \
fi
.PHONY: check-system-dep
check-system-dep: ## Checks if system dependencies are installed (nvcc) based on OS
@if ! command -v nvcc &> /dev/null; then \
echo "nvcc not found. Please install CUDA and set up your environment."; \
exit 1; \
fi
@if ! command -v uv &> /dev/null; then \
echo "uv not found. Please install uv with 'make install-uv'"; \
exit 1; \
fi
.PHONY: install-uv
install-uv: ## Installs uv package manger
@if ! command -v uv &> /dev/null; then \
echo "uv not found. Installing uv..."; \
curl -LsSf https://astral.sh/uv/0.9.7/install.sh | sh; \
echo "please follow the uv suggestions to update or restart your shell environment"; \
fi
@uv_version=$$(uv --version | awk '{print $$2}'); \
if [ "$$(printf '%s\n' "0.9.7" "$$uv_version" | sort -V | head -n1)" != "0.9.7" ]; then \
echo "Updating uv to latest version..."; \
uv self update 0.9.7; \
fi
.PHONY: install-python-dep
install-python-dep: ## Installs the Python dependencies
uv sync
.PHONY: compile
compile: check-system-dep ## Compiles the CUDA extension with nanobind
@echo "Compiling CUDA extension with nanobind..."
@echo "If you get an scikit-build-core error, you may need to 'uv cache clean' and 'trash build/'"
uv pip install scikit-build-core nanobind ninja cmake
uv sync --group build
# Not sure if the pip command is also needed
uv pip install -ve . --no-build-isolation
.PHONY: stubgen
stubgen: ## Generates the type-hint stub file for the nanobind-CUDA module
uv run --group build -m nanobind.stubgen -m mach._cuda_impl -O src/mach/
.PHONY: check
check: ## Checks the code
@echo "🚀 Checking lock file consistency with 'pyproject.toml'"
@uv lock --locked
@echo "🚀 Linting code: Running pre-commit"
@uv run pre-commit run -a
@echo "🚀 Type checking: Running ty"
@uv run ty check src
@echo "🚀 Checking for obsolete dependencies: Running deptry"
@uv run deptry .
@echo "🚀 Checking marimo notebooks"
@uv run marimo check marimo
.PHONY: test
test: ## Runs Python tests
@echo "🚀 Running tests"
uv run --group test --group array --group compare pytest tests -v -s --benchmark-disable --save-output
.PHONY: test-fail
test-fail: ## Runs Python tests that failed, and drop into debugger on failure
@echo "🚀 Running tests"
uv run --group test --group array --group compare pytest tests -v -s --benchmark-disable --save-output --pdb --lf
.PHONY: benchmark
benchmark: ## Runs benchmarking comparisons
@echo "🚀 Running benchmarking comparisons"
uv run --group test --group array --group compare pytest tests -v -s --benchmark-only --benchmark-histogram --benchmark-autosave --benchmark-save-data
.PHONY: profile
profile: ## Runs Python test with simple profiling. Recommend using Nsight Compute or Nsight Systems for more detailed profiling.
@echo "Building with CUDA_PROFILE"
uv pip install --no-build-isolation -ve . -Ccmake.define.CMAKE_CUDA_FLAGS_INIT="-DCUDA_PROFILE"
@echo "🚀 Running tests"
uv run --group profile pyinstrument --timeline -m pytest tests/test_beamform.py -v -s --tile-total-frames 200
.PHONY: docs
docs: ## Build the documentation
@echo "🚀 Building documentation"
uv run $(MAKE) -C docs html;
.PHONY: docs-open
docs-open: docs ## Build and open the documentation
@if [ -n "$$SSH_CONNECTION" ]; then \
@echo "🚀 Serving documentation"; \
uv run python -m http.server --directory docs/_build/html 8000; \
else \
@echo "🚀 Opening documentation in browser"; \
uv run python -c "import webbrowser; webbrowser.open_new_tab('file://$(PWD)/docs/_build/html/index.html')"; \
fi
.PHONY: wheel
wheel: ## Builds a wheel
uv build
.PHONY: clean
clean: ## Cleans build artifacts
@echo "Cleaning build artifacts..."
rm -rf dist/ build/ mach.*.so
.PHONY: docker-build
docker-build: ## Builds the Docker development image
docker compose build
.PHONY: docker-dev
docker-dev: ## Runs the development container
docker compose run --rm dev
.DEFAULT_GOAL := help