|
1 | 1 | # NetGraph Development Makefile |
2 | 2 | # This Makefile provides convenient shortcuts for common development tasks |
3 | 3 |
|
4 | | -.PHONY: help venv clean-venv dev install check check-ci lint format test qt clean docs docs-serve docs-diagrams build check-dist publish-test publish validate perf info check-python |
| 4 | +.PHONY: help venv clean-venv dev install check check-ci lint format test qt clean docs docs-serve docs-diagrams build check-dist publish-test publish validate perf info check-python hooks |
5 | 5 |
|
6 | 6 | # Default target - show help |
7 | 7 | .DEFAULT_GOAL := help |
@@ -51,14 +51,23 @@ help: |
51 | 51 | @echo "" |
52 | 52 | @echo "Utilities:" |
53 | 53 | @echo " make info - Show project information" |
| 54 | + @echo " make hooks - Run pre-commit on all files" |
54 | 55 | @echo " make check-python - Check if venv Python matches system Python" |
55 | 56 |
|
56 | 57 | # Setup and Installation |
57 | 58 | dev: |
58 | 59 | @echo "🚀 Setting up development environment..." |
59 | 60 | @if [ ! -x "$(VENV_BIN)/python" ]; then \ |
| 61 | + if [ -z "$(PY_FIND)" ]; then \ |
| 62 | + echo "❌ Error: No Python interpreter found (python3 or python)"; \ |
| 63 | + exit 1; \ |
| 64 | + fi; \ |
60 | 65 | echo "🐍 Creating virtual environment with $(PY_FIND) ..."; \ |
61 | | - $(PY_FIND) -m venv venv; \ |
| 66 | + $(PY_FIND) -m venv venv || { echo "❌ Failed to create venv"; exit 1; }; \ |
| 67 | + if [ ! -x "$(VENV_BIN)/python" ]; then \ |
| 68 | + echo "❌ Error: venv creation failed - $(VENV_BIN)/python not found"; \ |
| 69 | + exit 1; \ |
| 70 | + fi; \ |
62 | 71 | $(VENV_BIN)/python -m pip install -U pip wheel; \ |
63 | 72 | fi |
64 | 73 | @echo "📦 Installing dev dependencies..." |
|
70 | 79 |
|
71 | 80 | venv: |
72 | 81 | @echo "🐍 Creating virtual environment in ./venv ..." |
73 | | - @$(PY_FIND) -m venv venv |
| 82 | + @if [ -z "$(PY_FIND)" ]; then \ |
| 83 | + echo "❌ Error: No Python interpreter found (python3 or python)"; \ |
| 84 | + exit 1; \ |
| 85 | + fi |
| 86 | + @$(PY_FIND) -m venv venv || { echo "❌ Failed to create venv"; exit 1; } |
| 87 | + @if [ ! -x "$(VENV_BIN)/python" ]; then \ |
| 88 | + echo "❌ Error: venv creation failed - $(VENV_BIN)/python not found"; \ |
| 89 | + exit 1; \ |
| 90 | + fi |
74 | 91 | @$(VENV_BIN)/python -m pip install -U pip wheel |
75 | 92 | @echo "✅ venv ready. Activate with: source venv/bin/activate" |
76 | 93 |
|
@@ -236,6 +253,10 @@ info: |
236 | 253 | fi; \ |
237 | 254 | fi |
238 | 255 |
|
| 256 | +hooks: |
| 257 | + @echo "🔗 Running pre-commit on all files..." |
| 258 | + @$(PRECOMMIT) run --all-files || (echo "Some pre-commit hooks failed. Fix and re-run." && exit 1) |
| 259 | + |
239 | 260 | check-python: |
240 | 261 | @if [ -x "$(VENV_BIN)/python" ]; then \ |
241 | 262 | VENV_VER=$$($(VENV_BIN)/python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>/dev/null || echo "unknown"); \ |
|
0 commit comments