From 0772900e2a3ec32a5072231d3a1b8b262554a04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Fri, 23 Oct 2026 07:42:21 +0200 Subject: [PATCH] flow: run variables.json readers through PYTHON_EXE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit erase_non_stage_variables ran non_stage_variables.py through its "#!/usr/bin/env python3" shebang, so it used whichever python3 was first on PATH rather than PYTHON_EXE. In the Bazel sandbox that is the host interpreter, which need not have PyYAML. variables.mk ran defaults.py with $(PYTHON_EXE) before PYTHON_EXE was assigned, so in a plain make invocation it expanded empty and the shebang picked the interpreter there as well. Move the assignment above the defaults.py call. Refs #4180 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Øyvind Harboe --- flow/scripts/util.tcl | 3 ++- flow/scripts/variables.mk | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index 231a5b2c0e..ed00f5aefc 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -215,7 +215,8 @@ proc erase_non_stage_variables { stage_name } { # Tcl yaml package can't be imported in the sta/openroad environment: # # https://github.com/The-OpenROAD-Project/OpenROAD/issues/5875 - set variables [exec $::env(SCRIPTS_DIR)/non_stage_variables.py $stage_name] + set variables [exec -- $::env(PYTHON_EXE) \ + $::env(SCRIPTS_DIR)/non_stage_variables.py $stage_name] foreach var $variables { if { [info exists ::env($var)] } { unset ::env($var) diff --git a/flow/scripts/variables.mk b/flow/scripts/variables.mk index 355f4dd0bf..fd48cba625 100644 --- a/flow/scripts/variables.mk +++ b/flow/scripts/variables.mk @@ -39,6 +39,13 @@ endif include $(PLATFORM_DIR)/config.mk +# defaults.py below runs with PYTHON_EXE, so set it first. See the dragons +# comment near "setup all commands used within this flow" for why. +ifeq ($(origin PYTHON_EXE), undefined) + PYTHON_EXE := $(shell command -v python3) +endif +export PYTHON_EXE + # __SPACE__ is a workaround for whitespace hell in "foreach"; there # is no way to escape space in defaults.py and get "foreach" to work. $(foreach line,$(shell $(PYTHON_EXE) $(SCRIPTS_DIR)/defaults.py),$(eval export $(subst __SPACE__, ,$(line)))) @@ -104,12 +111,9 @@ export NUM_CORES # Python is not built by ORFS, and as such its absolute path has to be fetched # from the environment. Use `ifeq ($(origin PYTHON_EXE), undefined)` to check if # the variable hasn't been defined yet and run a single shell instance to fetch -# the absolute path if so. The other tools should've been built by ORFS, and can -# use a pre-specified path, which we can just use ?= for. -ifeq ($(origin PYTHON_EXE), undefined) - PYTHON_EXE := $(shell command -v python3) -endif -export PYTHON_EXE +# the absolute path if so. That is done further up, before defaults.py runs. +# The other tools should've been built by ORFS, and can use a pre-specified +# path, which we can just use ?= for. export RUN_CMD = $(PYTHON_EXE) $(FLOW_HOME)/scripts/run_command.py