-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (106 loc) · 4.2 KB
/
Copy pathMakefile
File metadata and controls
128 lines (106 loc) · 4.2 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
123
124
125
126
127
128
.PHONY: help install dev build test lint format clean wheels
# Configuration
PYTHON := python
SRC_DIR := src
TEST_DIR := tests
# Colors
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
# ============================================================================
# Help
# ============================================================================
help:
@echo "$(BLUE)kh57 - Development Commands$(NC)"
@echo ""
@echo "$(GREEN)Setup:$(NC)"
@echo " make install - Create venv + install dependencies"
@echo " make dev - Full dev setup (install + build + test)"
@echo ""
@echo "$(GREEN)Development:$(NC)"
@echo " make build - Build cython extensions in-place"
@echo " make test - Run all tests"
@echo ""
@echo "$(GREEN)Code Quality:$(NC)"
@echo " make format - Format code with ruff"
@echo " make lint - Check code with ruff"
@echo " make format-check - Check formatting without changes"
@echo ""
@echo "$(GREEN)Distribution:$(NC)"
@echo " make wheels - Build manylinux wheels via docker"
@echo ""
@echo "$(GREEN)Cleanup:$(NC)"
@echo " make clean - Remove build artifacts"
# ============================================================================
# Setup
# ============================================================================
check-uv:
@command -v uv >/dev/null 2>&1 || { \
echo "$(YELLOW)uv is not installed$(NC)"; \
echo "See: https://astral.sh/uv"; \
exit 1; \
}
install: check-uv
@echo "$(BLUE)Creating virtual environment...$(NC)"
uv venv
@echo "$(BLUE)Installing dependencies...$(NC)"
uv pip install -e ".[dev,test]"
@echo "$(GREEN)Installation complete$(NC)"
dev: install build test
@echo ""
@echo "$(GREEN)Development environment ready!$(NC)"
# ============================================================================
# Build
# ============================================================================
build:
@echo "$(BLUE)Building Cython extensions...$(NC)"
$(PYTHON) setup.py build_ext --inplace
@echo "$(GREEN)Extensions built$(NC)"
# ============================================================================
# Testing
# ============================================================================
test:
@echo "$(BLUE)Running tests...$(NC)"
pytest $(TEST_DIR) -q
test-cov:
@echo "$(BLUE)Running tests with coverage...$(NC)"
pytest $(TEST_DIR) --cov=kh57 --cov-report=html:tests/reports/coverage --cov-report=term-missing --cov-branch
# ============================================================================
# Code Quality
# ============================================================================
lint:
@echo "$(BLUE)Running linters...$(NC)"
ruff check $(SRC_DIR)/kh57 $(TEST_DIR)
format:
@echo "$(BLUE)Formatting code...$(NC)"
ruff format $(SRC_DIR)/kh57 $(TEST_DIR)
ruff check --fix $(SRC_DIR)/kh57 $(TEST_DIR)
@echo "$(GREEN)Code formatted$(NC)"
format-check:
@echo "$(BLUE)Checking code format...$(NC)"
ruff format --check $(SRC_DIR)/kh57 $(TEST_DIR)
ruff check $(SRC_DIR)/kh57 $(TEST_DIR)
# ============================================================================
# Wheels (docker-based manylinux)
# ============================================================================
wheels:
@echo "$(BLUE)Building manylinux wheels via docker...$(NC)"
docker build -t kh57-wheels -f Dockerfile .
docker run --rm -v $(PWD)/wheelhouse:/opt/kh57/manylinux_dist kh57-wheels
@echo "$(GREEN)Wheels in wheelhouse/$(NC)"
# ============================================================================
# Cleanup
# ============================================================================
clean:
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
rm -rf build/ dist/ *.egg-info/ wheelhouse/
find $(SRC_DIR) -type f -name "*.c" -delete 2>/dev/null || true
find $(SRC_DIR) -type f -name "*.cpp" -delete 2>/dev/null || true
find $(SRC_DIR) -type f -name "*.so" -delete 2>/dev/null || true
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
@echo "$(GREEN)Clean complete$(NC)"
clean-all: clean
rm -rf .venv/ .pytest_cache/ .ruff_cache/ .mypy_cache/
@echo "$(GREEN)Deep clean complete$(NC)"