diff --git a/Makefile b/Makefile index af982516..e9ed6dfe 100644 --- a/Makefile +++ b/Makefile @@ -58,11 +58,11 @@ zephyr-setup: fprime-venv ## Set up Zephyr environment .PHONY: pre-commit-install pre-commit-install: uv ## Install pre-commit hooks - @$(UVX) pre-commit install > /dev/null + @$(UVX_PINNED) pre-commit install > /dev/null .PHONY: fmt fmt: pre-commit-install ## Lint and format files - @$(UVX) pre-commit run --all-files + @$(UVX_PINNED) pre-commit run --all-files .PHONY: data-budget data-budget: fprime-venv ## Analyze telemetry data budget (use VERBOSE=1 for detailed output) diff --git a/makelib/build-tools.mk b/makelib/build-tools.mk index 9e346c8f..f2dfb4d1 100644 --- a/makelib/build-tools.mk +++ b/makelib/build-tools.mk @@ -10,10 +10,19 @@ $(TOOLS_DIR): ### Tool Versions UV_VERSION ?= 0.8.13 +### Python version used for tooling environments. Single source of truth is .python-version, so +### that tools do not silently build against whichever interpreter happens to be on the machine. +PYTHON_VERSION ?= $(shell cat .python-version) + ### uv & uvx UV_DIR ?= $(TOOLS_DIR)/uv-$(UV_VERSION) UV ?= $(UV_DIR)/uv UVX ?= $(UV_DIR)/uvx +### Pin the interpreter for uvx-run tooling. pre-commit builds its hook environments with whatever +### Python runs it, so without this a machine defaulting to an older interpreter builds hook +### environments that cannot parse project sources written for .python-version. uv downloads the +### pinned interpreter if it is missing. +UVX_PINNED ?= $(UVX) --python $(PYTHON_VERSION) .PHONY: uv uv: $(UV) ## Download uv $(UV): $(TOOLS_DIR)