From a490fbe9f74942aba123076ad329bbda446b4d21 Mon Sep 17 00:00:00 2001 From: Daniel Keller Date: Tue, 16 Jun 2026 11:48:29 +0200 Subject: [PATCH] build: Self-bootstrap the uv env for make idma_hw_all Generating the RTL needs Mako/peakrdl. Previously the caller had to set up the venv (uv sync + activate, or uv run make). Detect when those deps are not importable and provision a local .venv via uv sync --locked, prepending it to PATH. An activated venv or 'uv run make' (CI) is detected and left untouched, so behavior there is unchanged. Lets a consumer (e.g. a cluster) just call 'make -C $(bender path idma) idma_hw_all'. Requires uv on PATH. --- idma.mk | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/idma.mk b/idma.mk index 04f0bdd9..e76fab2a 100644 --- a/idma.mk +++ b/idma.mk @@ -17,6 +17,24 @@ VERILATOR ?= verilator VLOGAN ?= vlogan VSIM ?= vsim +# Provision a local uv venv when the generator deps are not already available. +IDMA_VENV_PY := $(IDMA_ROOT)/.venv/bin/python +ifeq ($(shell $(PYTHON) -c 'import mako' >/dev/null 2>&1 && echo ok),ok) +else ifeq ($(shell $(IDMA_VENV_PY) -c 'import mako' >/dev/null 2>&1 && echo ok),ok) + PYTHON := $(IDMA_VENV_PY) + export PATH := $(IDMA_ROOT)/.venv/bin:$(PATH) +else ifeq ($(shell command -v uv >/dev/null 2>&1 && echo ok),ok) + $(info iDMA: provisioning the generator environment (uv sync --locked) ...) + _idma_uv_sync := $(shell cd $(IDMA_ROOT) && uv sync --locked 1>&2 || echo FAIL) + ifeq ($(_idma_uv_sync),FAIL) + $(error iDMA: 'uv sync --locked' failed; see output above) + endif + PYTHON := $(IDMA_VENV_PY) + export PATH := $(IDMA_ROOT)/.venv/bin:$(PATH) +else + $(error iDMA RTL generation needs 'uv' (https://docs.astral.sh/uv) on PATH, or a venv with the pyproject.toml deps activated) +endif + # Shell SHELL := /bin/bash