diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 74af6c1b5e..6078484934 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -402,6 +402,11 @@ def system_test_dir(request, system_test_name, expected_artifacts): # Log which binaries are used for the test(s) isctest.log.info("testing binaries from: %s", os.environ.get("TOP_BUILDDIR")) + # Log what Python interpreter is used to run the test(s) + isctest.log.info( + "using Python interpreter at: %s to run the test(s)", os.environ.get("PYTHON") + ) + # System tests are meant to be executed from their directory - switch to it. old_cwd = os.getcwd() os.chdir(testdir) diff --git a/bin/tests/system/isctest/vars/build.py b/bin/tests/system/isctest/vars/build.py index 18ceca9a00..e8978d088d 100644 --- a/bin/tests/system/isctest/vars/build.py +++ b/bin/tests/system/isctest/vars/build.py @@ -11,6 +11,8 @@ from pathlib import Path +import sys + SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system" @@ -53,6 +55,17 @@ def load_vars_from_build_files() -> dict[str, str]: if var_file.exists(): build_vars[var] = var_file.read_text(encoding="utf-8").strip() + # When running inside a virtualenv, prefer the virtualenv's interpreter + # over the path baked in by meson. + # This is needed because meson is configured to prefer specific versions + # (e.g. python3.12 and python3.11) by default to properly detect the + # right python interpreter in CI - this is undesirable when running + # in a virtualenv as it can lead to the system tests using the system + # versions of Python dependencies defeating the purpose of the virtual + # environment. + if sys.prefix != sys.base_prefix: + build_vars["PYTHON"] = sys.executable + return build_vars