Skip to content

Commit de389f3

Browse files
committed
Refactor Makefile to prefer project virtual environment for toolchain commands
1 parent 7ba78cf commit de389f3

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

Makefile

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
# Default target - show help
77
.DEFAULT_GOAL := help
88

9-
# Toolchain
10-
PYTHON ?= python3
11-
PIP ?= $(PYTHON) -m pip
12-
PYTEST ?= pytest
9+
# Toolchain (prefer project venv if present)
10+
VENV_BIN := $(PWD)/ngraph-venv/bin
11+
PYTHON := $(if $(wildcard $(VENV_BIN)/python),$(VENV_BIN)/python,python3)
12+
PIP := $(PYTHON) -m pip
13+
PYTEST := $(PYTHON) -m pytest
14+
RUFF := $(PYTHON) -m ruff
15+
PRECOMMIT := $(PYTHON) -m pre_commit
1316

1417
help:
1518
@echo "🔧 NetGraph Development Commands"
@@ -57,7 +60,7 @@ install:
5760
check:
5861
@echo "🔍 Running complete code quality checks and tests..."
5962
@$(MAKE) lint
60-
@bash dev/run-checks.sh
63+
@PYTHON=$(PYTHON) bash dev/run-checks.sh
6164

6265
check-ci:
6366
@echo "🔍 Running CI checks (non-mutating lint + schema validation + tests)..."
@@ -67,13 +70,13 @@ check-ci:
6770

6871
lint:
6972
@echo "🧹 Running linting checks (non-mutating)..."
70-
@ruff format --check .
71-
@ruff check .
73+
@$(RUFF) format --check .
74+
@$(RUFF) check .
7275
@$(PYTHON) -m pyright
7376

7477
format:
7578
@echo "✨ Auto-formatting code..."
76-
@ruff format .
79+
@$(RUFF) format .
7780

7881
test:
7982
@echo "🧪 Running tests with coverage (includes slow and benchmark)..."
@@ -117,8 +120,8 @@ docs-diagrams:
117120

118121
docs-serve:
119122
@echo "🌐 Serving documentation locally..."
120-
@if command -v mkdocs >/dev/null 2>&1; then \
121-
mkdocs serve; \
123+
@if $(PYTHON) -c "import mkdocs" >/dev/null 2>&1; then \
124+
$(PYTHON) -m mkdocs serve; \
122125
else \
123126
echo "❌ mkdocs not installed. Install dev dependencies with: make dev"; \
124127
exit 1; \
@@ -186,11 +189,11 @@ info:
186189
@echo " Virtual environment: $$(echo $$VIRTUAL_ENV | sed 's|.*/||' || echo 'None active')"
187190
@echo ""
188191
@echo "🔧 Development Tools:"
189-
@echo " Pre-commit: $$(pre-commit --version 2>/dev/null || echo 'Not installed')"
192+
@echo " Pre-commit: $$($(PRECOMMIT) --version 2>/dev/null || echo 'Not installed')"
190193
@echo " Pytest: $$($(PYTEST) --version 2>/dev/null || echo 'Not installed')"
191-
@echo " Ruff: $$(ruff --version 2>/dev/null || echo 'Not installed')"
192-
@echo " Pyright: $$(pyright --version 2>/dev/null | head -1 || echo 'Not installed')"
193-
@echo " MkDocs: $$(mkdocs --version 2>/dev/null | sed 's/mkdocs, version //' | sed 's/ from.*//' || echo 'Not installed')"
194+
@echo " Ruff: $$($(RUFF) --version 2>/dev/null || echo 'Not installed')"
195+
@echo " Pyright: $$($(PYTHON) -m pyright --version 2>/dev/null | head -1 || echo 'Not installed')"
196+
@echo " MkDocs: $$($(PYTHON) -m mkdocs --version 2>/dev/null | sed 's/mkdocs, version //' | sed 's/ from.*//' || echo 'Not installed')"
194197
@echo " Build: $$($(PYTHON) -m build --version 2>/dev/null | sed 's/build //' | sed 's/ (.*//' || echo 'Not installed')"
195198
@echo " Twine: $$($(PYTHON) -m twine --version 2>/dev/null | grep -o 'twine version [0-9.]*' | cut -d' ' -f3 || echo 'Not installed')"
196199
@echo " JsonSchema: $$($(PYTHON) -c 'import importlib.metadata; print(importlib.metadata.version("jsonschema"))' 2>/dev/null || echo 'Not installed')"

0 commit comments

Comments
 (0)