From 68cfca178850fde0139906e61bce454412818d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Wed, 15 Apr 2026 08:08:01 +0000 Subject: [PATCH 1/2] Use virtualenv's Python interpreter when running tests from a venv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Meson bakes the absolute path of the detected Python binary (e.g. /usr/bin/python3.12) into the PYTHON build variable. When tests are run from a virtualenv, that stored path might point to the system Python which lacks the virtualenv's installed packages, causing test failures. Fix this by checking whether the current process is running inside a virtualenv (sys.prefix != sys.base_prefix) and, if so, replacing the stored PYTHON build var with sys.executable — the interpreter that is already running pytest and has all required dependencies available. The behaviour on EL8/EL9 (where meson prefers python3.12 over the older platform default) and on FreeBSD (python3.11) is unchanged, since those workflows run pytest without an active virtualenv in our CI. Co-Authored-By: Claude Sonnet 4.6 --- bin/tests/system/isctest/vars/build.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 From 261185ecb579c465056677144471d42413946fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 15 Apr 2026 15:12:38 +0200 Subject: [PATCH 2/2] Log the Python interpreter used to run the system tests during setup This is useful when running in an virtual environment or on a machine where multiple Python versions are installed. --- bin/tests/system/conftest.py | 5 +++++ 1 file changed, 5 insertions(+) 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)