SHELL := /bin/bash
PYTHON := $(shell command -v python3 2>/dev/null || command -v python)
VENV_DIR := .venv
ifeq ($(OS), Windows_NT)
VENV_ACTIVATE := $(VENV_DIR)/Scripts/activate
else
VENV_ACTIVATE := $(VENV_DIR)/bin/activate
endif
.PHONY: help venv clean purge build lint py-test rust-test test fmt
venv:
@if [ ! -d "$(VENV_DIR)" ]; then \
echo "Creating virtual environment with uv..."; \
$(PYTHON) -m uv venv $(VENV_DIR); \
fi
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
init: venv
@echo "Installing Python dependencies..."
@cp "README.md" "package-python/README_PYTHON.md"
@cp "LICENSE" "package-python/LICENSE"
@source $(VENV_ACTIVATE) && \
cd package-python && \
uv pip install -e ".[dev]" && \
cd .. && \
uv pip install pandas seaborn && \
python scripts/make_resources.py
@echo "Installing pre-commit hooks..."
@source $(VENV_ACTIVATE) && \
uv pip install pre-commit && \
pre-commit install
clean:
cargo clean
purge:
git clean -d -x -f
build:
cargo build
lint:
@rustup component add clippy 2> /dev/null
cargo clippy
py-test-sh: venv
@echo "Running Python tests..."
@source $(VENV_ACTIVATE) && \
bash scripts/run-python-tests.sh
py-test-ps: venv
@echo "Running Python tests..."
@source $(VENV_ACTIVATE) && \
powershell.exe -ExecutionPolicy Bypass -File scripts/run-python-tests.ps1
py-test-ps-single: venv
@echo "Running Python tests..."
@source $(VENV_ACTIVATE) && \
powershell.exe -ExecutionPolicy Bypass -File scripts/run-single-python-test.ps1
rust-test:
cargo test
test: venv
@echo "Running both Rust and Python tests..."
cargo test
@source $(VENV_ACTIVATE) && \
bash scripts/run-python-tests.sh
fmt:
@rustup component add rustfmt 2> /dev/null
cargo fmt
vendor-r:
@echo "Vendoring core Rust logic..."
$(PYTHON) scripts/vendor_r.py
gen-r-docs:
@echo "Generating R documentation..."
Rscript scripts/generate_r_docs.R