From d6fdd65894815ed7fe32b68ef8aaf6258272f5e0 Mon Sep 17 00:00:00 2001 From: Alberto Invernizzi Date: Thu, 2 Apr 2026 11:40:41 +0200 Subject: [PATCH] envvars now depends just on python stdlib we relied on yaml dep installed by the system. since yaml is not part of the python stdlib but json is, here we rely on bash process substitution to pass a temporary file translated by yq from yaml to json. --- stackinator/etc/envvars.py | 8 +------- stackinator/templates/Make.user | 2 ++ stackinator/templates/Makefile.environments | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/stackinator/etc/envvars.py b/stackinator/etc/envvars.py index 0f122057..7c63b6c8 100755 --- a/stackinator/etc/envvars.py +++ b/stackinator/etc/envvars.py @@ -7,8 +7,6 @@ from enum import Enum from typing import List, Optional -import yaml - class EnvVarOp(Enum): PREPEND = 1 @@ -504,12 +502,8 @@ def view_impl(args): envvars.remove_root(args.build_path) if args.compilers is not None: - if not os.path.isfile(args.compilers): - print(f"error - compiler yaml file {args.compilers} does not exist") - exit(1) - with open(args.compilers, "r") as file: - data = yaml.safe_load(file) + data = json.load(file) compilers = [] for p in data["packages"].values(): diff --git a/stackinator/templates/Make.user b/stackinator/templates/Make.user index cb8acb03..68c8f154 100644 --- a/stackinator/templates/Make.user +++ b/stackinator/templates/Make.user @@ -2,6 +2,8 @@ # Copy this file to Make.user and set some variables. +SHELL := bash + # This is the root of the software stack directory. BUILD_ROOT := {{ build_path }} diff --git a/stackinator/templates/Makefile.environments b/stackinator/templates/Makefile.environments index 5a530232..01929d9c 100644 --- a/stackinator/templates/Makefile.environments +++ b/stackinator/templates/Makefile.environments @@ -34,7 +34,7 @@ all:{% for env in environments %} {{ env }}/generated/build_cache{% endfor %} {{ env }}/generated/view_config: {{ env }}/generated/env {% for view in config.views %} $(SPACK) env activate --with-view {{ view.name }} --sh ./{{ env }} > $(STORE)/env/{{ view.name }}/activate.sh - $(BUILD_ROOT)/envvars.py view {% if view.extra.add_compilers %}--compilers=./{{ env }}/packages.yaml {% endif %} --prefix_paths="{{ view.extra.prefix_string }}" $(STORE)/env/{{ view.name }} $(BUILD_ROOT) + $(BUILD_ROOT)/envvars.py view {% if view.extra.add_compilers %}--compilers=<(yq read -j -p v ./{{ env }}/packages.yaml) {% endif %} --prefix_paths="{{ view.extra.prefix_string }}" $(STORE)/env/{{ view.name }} $(BUILD_ROOT) {% endfor %} touch $@