From 7ac41a1b2486eb38a5015fa38bb4d9f3ce001a98 Mon Sep 17 00:00:00 2001 From: Mara Furland Date: Mon, 7 Oct 2024 11:04:02 -0400 Subject: [PATCH] scripts: twister: set Python3_EXECUTABLE when calling cmake When twister calls cmake, set Python3_EXECUTABLE so things work as expected when using non-global python Signed-off-by: Mara Furland --- scripts/pylib/twister/twisterlib/runner.py | 4 +++- scripts/tests/twister/test_runner.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/pylib/twister/twisterlib/runner.py b/scripts/pylib/twister/twisterlib/runner.py index 9e4cf2443ac..f5e2cabf74d 100644 --- a/scripts/pylib/twister/twisterlib/runner.py +++ b/scripts/pylib/twister/twisterlib/runner.py @@ -20,6 +20,7 @@ from multiprocessing import Lock, Process, Value from multiprocessing.managers import BaseManager from typing import List from packaging import version +import pathlib from colorama import Fore from domains import Domains @@ -363,7 +364,8 @@ class CMake: f'-DTC_NAME={self.instance.testsuite.name}', f'-D{warning_command}={warnings_as_errors}', f'-DEXTRA_GEN_EDT_ARGS={gen_edt_args}', - f'-G{self.env.generator}' + f'-G{self.env.generator}', + f'-DPython3_EXECUTABLE={pathlib.Path(sys.executable).as_posix()}' ] # If needed, run CMake using the package_helper script first, to only run diff --git a/scripts/tests/twister/test_runner.py b/scripts/tests/twister/test_runner.py index e0a0ca51194..d2d0143d189 100644 --- a/scripts/tests/twister/test_runner.py +++ b/scripts/tests/twister/test_runner.py @@ -373,6 +373,7 @@ TESTDATA_2_2 = [ '-B' + os.path.join('build', 'dir'), '-DTC_RUNID=1', '-DTC_NAME=testcase', '-DSB_CONFIG_COMPILER_WARNINGS_AS_ERRORS=y', '-DEXTRA_GEN_EDT_ARGS=--edtlib-Werror', '-Gdummy_generator', + f'-DPython3_EXECUTABLE={pathlib.Path(sys.executable).as_posix()}', '-S' + os.path.join('source', 'dir'), 'arg1', 'arg2', '-DBOARD=', @@ -387,6 +388,7 @@ TESTDATA_2_2 = [ '-B' + os.path.join('build', 'dir'), '-DTC_RUNID=1', '-DTC_NAME=testcase', '-DSB_CONFIG_COMPILER_WARNINGS_AS_ERRORS=n', '-DEXTRA_GEN_EDT_ARGS=', '-Gdummy_generator', + f'-DPython3_EXECUTABLE={pathlib.Path(sys.executable).as_posix()}', '-Szephyr_base/share/sysbuild', '-DAPP_DIR=' + os.path.join('source', 'dir'), 'arg1', 'arg2',