Skip to content

Commit 3fc5b64

Browse files
committed
Enhance Makefile: Improve virtual environment setup with error handling, add build checks, and refine clean commands
1 parent 5a9a2bc commit 3fc5b64

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

Makefile

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NetGraph-Core Development Makefile
22

3-
.PHONY: help venv clean-venv dev install check check-ci lint format test qt clean build info hooks cov cpp-test rebuild check-python
3+
.PHONY: help venv clean-venv dev install check check-ci lint format test qt clean build info hooks cov cpp-test rebuild check-python sanitize-test
44

55
.DEFAULT_GOAL := help
66

@@ -48,8 +48,16 @@ DEV_ENV := $(ENV_MACOS) $(ENV_CC) $(ENV_CXX) $(ENV_CMAKE)
4848
dev:
4949
@echo "🚀 Setting up development environment..."
5050
@if [ ! -x "$(VENV_BIN)/python" ]; then \
51+
if [ -z "$(PY_FIND)" ]; then \
52+
echo "❌ Error: No Python interpreter found (python3 or python)"; \
53+
exit 1; \
54+
fi; \
5155
echo "🐍 Creating virtual environment with $(PY_FIND) ..."; \
52-
$(PY_FIND) -m venv venv; \
56+
$(PY_FIND) -m venv venv || { echo "❌ Failed to create venv"; exit 1; }; \
57+
if [ ! -x "$(VENV_BIN)/python" ]; then \
58+
echo "❌ Error: venv creation failed - $(VENV_BIN)/python not found"; \
59+
exit 1; \
60+
fi; \
5361
$(VENV_BIN)/python -m pip install -U pip wheel; \
5462
fi
5563
@echo "📦 Installing dev dependencies..."
@@ -61,7 +69,15 @@ dev:
6169

6270
venv:
6371
@echo "🐍 Creating virtual environment in ./venv ..."
64-
@$(PY_FIND) -m venv venv
72+
@if [ -z "$(PY_FIND)" ]; then \
73+
echo "❌ Error: No Python interpreter found (python3 or python)"; \
74+
exit 1; \
75+
fi
76+
@$(PY_FIND) -m venv venv || { echo "❌ Failed to create venv"; exit 1; }
77+
@if [ ! -x "$(VENV_BIN)/python" ]; then \
78+
echo "❌ Error: venv creation failed - $(VENV_BIN)/python not found"; \
79+
exit 1; \
80+
fi
6581
@$(VENV_BIN)/python -m pip install -U pip wheel
6682
@echo "✅ venv ready. Activate with: source venv/bin/activate"
6783

@@ -94,16 +110,27 @@ test:
94110
@$(PYTEST)
95111

96112
qt:
97-
@$(PYTEST) -m "not slow and not benchmark"
113+
@$(PYTEST) --no-cov -m "not slow and not benchmark"
98114

99115
build:
100-
@$(PYTHON) -m build
116+
@echo "🏗️ Building distribution packages..."
117+
@if $(PYTHON) -c "import build" >/dev/null 2>&1; then \
118+
$(PYTHON) -m build; \
119+
else \
120+
echo "❌ build module not installed. Install dev dependencies with: make dev"; \
121+
exit 1; \
122+
fi
101123

102124
clean:
103-
@rm -rf build/ dist/ *.egg-info/ **/__pycache__ */__pycache__
125+
@echo "🧹 Cleaning build artifacts and cache files..."
126+
@rm -rf build/ dist/ *.egg-info/
127+
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
128+
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
129+
@find . -type f -name "*.pyo" -delete 2>/dev/null || true
104130
@rm -f .coverage coverage-*.xml coverage-*.html
105131
@rm -rf htmlcov-python
106132
@rm -rf Testing CTestTestfile.cmake
133+
@echo "✅ Cleanup complete!"
107134

108135
info:
109136
@echo "Python (active): $$($(PYTHON) --version)"

0 commit comments

Comments
 (0)