From 63b60b00bbf3cecdee267415f3d56aba8deff21d Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 11 Jul 2026 03:25:04 +0200 Subject: [PATCH] fix(env): parse the group_vars paths SPOT without PyYAML The new dir handlers pulled utils.cache.yaml into the env build, which bootstrap runs (make install-system-python) before any Python dependency exists; on arch and manjaro, whose images ship no preinstalled PyYAML, the .env generation died with ModuleNotFoundError and broke PKGMGR and the dev environment jobs. Read the plain KEY: "value" entries with a stdlib line parser instead; Jinja values and missing keys stay hard errors. Co-Authored-By: Claude Opus 4.8 --- .pre-commit-config.yaml | 8 ++++++++ Makefile | 5 ++--- utils/paths.py | 35 ++++++++++++++++++++++++----------- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0898b6ec2a..287864cd1e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,6 +22,14 @@ repos: always_run: true stages: - pre-merge-commit + - id: make-lint + name: Run make lint (pre-push gate) + entry: make lint + language: system + pass_filenames: false + always_run: true + stages: + - pre-push - id: make-test-main-merged name: Run make test-main-merged (pre-push gate) entry: make test-main-merged diff --git a/Makefile b/Makefile index 18df93a0eb..b731a61f5d 100644 --- a/Makefile +++ b/Makefile @@ -637,11 +637,10 @@ system-purge: @bash scripts/system/purge/system.sh .PHONY: test -# Run the full test pipeline (lint + tests). +# Run the full test pipeline. # Note: parallel execution with fail-fast. -test: install install-lint +test: install @bash scripts/make/parallel.sh \ - lint \ test-external \ test-integration \ test-lint \ diff --git a/utils/paths.py b/utils/paths.py index 489960154a..dbbd3d5fed 100644 --- a/utils/paths.py +++ b/utils/paths.py @@ -5,19 +5,28 @@ The env layer (utils/env/handlers, exported by scripts/meta/env/load.sh) derives the ``INFINITO_*`` env keys from it; a set env wins so callers can override. When a tool runs outside that layer, e.g. a bare ``subprocess`` that does not inherit the env build, the value is read straight from the group_vars SPOT, so -there is still no hardcoded literal default. Only plain-string values can be -read this way; a Jinja expression in the SPOT is a hard error. +there is still no hardcoded literal default. + +The SPOT is parsed with a plain-string line parser instead of PyYAML: the env +build runs during bootstrap (make install-system-python) before any Python +dependency exists, so this module must stay stdlib-only. Only plain +``KEY: "value"`` entries can be read this way; a Jinja expression or a missing +key is a hard error. """ from __future__ import annotations import os +import re from pathlib import Path from utils import PROJECT_ROOT -from utils.cache.yaml import load_yaml +from utils.cache.files import read_text _GROUP_PATHS_FILE = str(PROJECT_ROOT / "group_vars" / "all" / "05_paths.yml") +_ENTRY_RE = re.compile( + r'^(?P[A-Za-z_][A-Za-z0-9_]*):\s*"?(?P[^"#]*)"?\s*(?:#.*)?$' +) def read_group_path(key: str) -> str: @@ -33,14 +42,18 @@ def read_group_path(key: str) -> str: KeyError: the key is not defined in the SPOT. ValueError: the value is not a plain string (e.g. a Jinja template). """ - value = load_yaml(_GROUP_PATHS_FILE).get(key) - if value is None: - raise KeyError(f"{key} not defined in {_GROUP_PATHS_FILE}") - if not isinstance(value, str) or "{{" in value: - raise ValueError( - f"{key} in {_GROUP_PATHS_FILE} must be a plain string, got: {value!r}" - ) - return value + for line in read_text(_GROUP_PATHS_FILE).splitlines(): + match = _ENTRY_RE.match(line.strip()) + if not match or match.group("key") != key: + continue + value = match.group("value").strip() + if not value or "{{" in value: + raise ValueError( + f"{key} in {_GROUP_PATHS_FILE} must be a plain string, " + f"got: {line.strip()!r}" + ) + return value + raise KeyError(f"{key} not defined in {_GROUP_PATHS_FILE}") def _dir_var_lib() -> str: