From ae9b5dae77ef140422fcf71d239ca028c9208447 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Sat, 10 May 2025 09:43:48 +0100 Subject: [PATCH] oeqa/sdk/maturin: be less picky in the list_python test The test assumed that maturin would only find a single Python binary, in /usr/bin/python3*. However in eSDKs with buildtools a Python is shipped with the SDK, so the test failed. Generalise the test so that it runs python3 and obtains its path and version, and then verifies that path and and version are found by Maturin. This means we're not assuming a single Python, or the paths, or that the Python is CPython. Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- meta/lib/oeqa/sdk/cases/maturin.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py index 42394c7a973..83d13c4ec59 100644 --- a/meta/lib/oeqa/sdk/cases/maturin.py +++ b/meta/lib/oeqa/sdk/cases/maturin.py @@ -19,17 +19,15 @@ class MaturinTest(OESDKTestCase): self.ensure_host_package("python3-maturin") def test_maturin_list_python(self): - py_major = self._run("python3 -c 'import sys; print(sys.version_info.major)'") - py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'") - python_version = "%s.%s" % (py_major.strip(), py_minor.strip()) - cmd = "maturin list-python" - output = self._run(cmd) - self.assertRegex(output, r"^🐍 1 python interpreter found:\n") - self.assertRegex( - output, - r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), - ) + out = self._run(r"""python3 -c 'import sys; print(f"{sys.executable}\n{sys.version_info.major}.{sys.version_info.minor}")'""") + executable, version = out.splitlines() + output = self._run("maturin list-python") + # The output looks like this: + # - CPython 3.13 at /usr/bin/python3 + # We don't want to assume CPython so just check for the version and path. + expected = f"{version} at {executable}" + self.assertIn(expected, output) class MaturinDevelopTest(OESDKTestCase): @classmethod -- 2.47.3