Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (92 loc) · 3.24 KB
/
Copy pathMakefile
File metadata and controls
111 lines (92 loc) · 3.24 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
.PHONY: build test install uninstall test_deps dist_deps dist dist_wheel upload clean docs ensure-uv install-nn
SHELL = /bin/bash
# Detect CI environment
ifdef CI
# In CI: use system Python and pip
PYTHON = python3
PIP = pip3
PIP_FLAGS =
else
# Locally: use uv if available, otherwise fall back to system
PYTHON = python3
PIP = pip3
PIP_FLAGS =
# Check if uv is available
ifneq ($(shell command -v uv 2> /dev/null),)
PIP = uv pip
PIP_FLAGS = --system
endif
endif
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = toad
DOCSDIR = docs
SOURCEDIR := $(DOCSDIR)/source
BUILDDIR := $(DOCSDIR)/build
# Check if uv is installed, if not install it
ensure-uv:
@command -v uv >/dev/null 2>&1 || (echo "Installing uv..." && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH="$$HOME/.local/bin:$$PATH")
install: ensure-uv build
@echo "Installing with $(PIP)..."
$(PIP) install $(PIP_FLAGS) -e .
install-nn: ensure-uv build
@echo "Installing with neural network support..."
$(PIP) install $(PIP_FLAGS) -e .[nn]
uninstall:
cat files.txt | xargs rm -rf
test_deps: ensure-uv
@echo "Installing test dependencies..."
$(PIP) install $(PIP_FLAGS) -r requirements-test.txt
test: test_deps
$(eval TARGET := $(filter-out $@, $(MAKECMDGOALS)))
@if [ -z "$(TARGET)" ]; then \
$(PYTHON) -m pytest -x toad --ignore=toad/nn; \
else \
$(PYTHON) -m pytest -s $(TARGET); \
fi
test-nn: test_deps install-nn
@echo "Running tests with neural network support..."
$(PYTHON) -m pytest -x toad
build_deps: ensure-uv
@echo "Installing build dependencies..."
$(PIP) install $(PIP_FLAGS) -r requirements.txt
$(PIP) install $(PIP_FLAGS) maturin
build: build_deps
@echo "Building Rust extension with maturin..."
$(PYTHON) -m maturin build --release
@echo "Installing toad_core from wheel..."
ifdef CI
# In CI: directly install wheel
$(PIP) install --force-reinstall --no-deps target/wheels/toad-*.whl
else
# Locally: extract and copy toad_core to preserve editable install
@rm -rf /tmp/toad_wheel_extract && mkdir -p /tmp/toad_wheel_extract
@cd /tmp/toad_wheel_extract && unzip -q $(CURDIR)/target/wheels/toad-*.whl "toad_core/*" 2>/dev/null || true
@if [ -d "/tmp/toad_wheel_extract/toad_core" ]; then \
rm -rf .venv/lib/python*/site-packages/toad_core 2>/dev/null || true; \
mkdir -p .venv/lib/python*/site-packages/ 2>/dev/null || true; \
cp -r /tmp/toad_wheel_extract/toad_core .venv/lib/python*/site-packages/ 2>/dev/null || true; \
echo "toad_core module installed to .venv"; \
else \
echo "Warning: Could not extract toad_core, may need manual installation"; \
fi
endif
dist_deps: ensure-uv
@echo "Installing distribution dependencies..."
$(PIP) install $(PIP_FLAGS) -U -r requirements-dist.txt
dist: build dist_deps
$(PYTHON) -m maturin build --release
dist_wheel: build_deps dist_deps
@rm -rf target/wheels/*
$(PYTHON) -m maturin build --release --compression-method stored
upload:
$(PYTHON) -m twine check dist/*
@$(PYTHON) -m twine upload dist/* -u $(TWINE_USER) -p $(TWINE_PASS)
clean:
@rm -rf build/ dist/ *.egg-info/ **/__pycache__/
@rm -rf toad/*.c toad/*.so target/ Cargo.lock
@rm -rf toad/*.pyx toad/*.pxd
docs: build
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
%:
@: