diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/cases/maturin.py')
-rw-r--r-- | meta/lib/oeqa/sdk/cases/maturin.py | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py index 20f6b553d0..e3e8edc781 100644 --- a/meta/lib/oeqa/sdk/cases/maturin.py +++ b/meta/lib/oeqa/sdk/cases/maturin.py | |||
@@ -16,44 +16,24 @@ errors_have_output() | |||
16 | 16 | ||
17 | class MaturinTest(OESDKTestCase): | 17 | class MaturinTest(OESDKTestCase): |
18 | def setUp(self): | 18 | def setUp(self): |
19 | if not ( | 19 | self.ensure_host_package("python3-maturin") |
20 | self.tc.hasHostPackage("nativesdk-python3-maturin") | ||
21 | or self.tc.hasHostPackage("python3-maturin-native") | ||
22 | ): | ||
23 | raise unittest.SkipTest("No python3-maturin package in the SDK") | ||
24 | 20 | ||
25 | def test_maturin_list_python(self): | 21 | def test_maturin_list_python(self): |
26 | py_major = self._run("python3 -c 'import sys; print(sys.version_info.major)'") | 22 | out = self._run(r"""python3 -c 'import sys; print(f"{sys.executable}\n{sys.version_info.major}.{sys.version_info.minor}")'""") |
27 | py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'") | 23 | executable, version = out.splitlines() |
28 | python_version = "%s.%s" % (py_major.strip(), py_minor.strip()) | ||
29 | cmd = "maturin list-python" | ||
30 | output = self._run(cmd) | ||
31 | self.assertRegex(output, r"^🐍 1 python interpreter found:\n") | ||
32 | self.assertRegex( | ||
33 | output, | ||
34 | r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), | ||
35 | ) | ||
36 | 24 | ||
25 | output = self._run("maturin list-python") | ||
26 | # The output looks like this: | ||
27 | # - CPython 3.13 at /usr/bin/python3 | ||
28 | # We don't want to assume CPython so just check for the version and path. | ||
29 | expected = f"{version} at {executable}" | ||
30 | self.assertIn(expected, output) | ||
37 | 31 | ||
38 | class MaturinDevelopTest(OESDKTestCase): | 32 | class MaturinDevelopTest(OESDKTestCase): |
39 | @classmethod | ||
40 | def setUpClass(self): | ||
41 | targetdir = os.path.join(self.tc.sdk_dir, "guessing-game") | ||
42 | try: | ||
43 | shutil.rmtree(targetdir) | ||
44 | except FileNotFoundError: | ||
45 | pass | ||
46 | shutil.copytree( | ||
47 | os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir | ||
48 | ) | ||
49 | |||
50 | def setUp(self): | 33 | def setUp(self): |
51 | machine = self.td.get("MACHINE") | 34 | machine = self.td.get("MACHINE") |
52 | if not ( | 35 | self.ensure_host_package("python3-maturin") |
53 | self.tc.hasHostPackage("nativesdk-python3-maturin") | 36 | |
54 | or self.tc.hasHostPackage("python3-maturin-native") | ||
55 | ): | ||
56 | raise unittest.SkipTest("No python3-maturin package in the SDK") | ||
57 | if not ( | 37 | if not ( |
58 | self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine) | 38 | self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine) |
59 | ): | 39 | ): |
@@ -67,9 +47,17 @@ class MaturinDevelopTest(OESDKTestCase): | |||
67 | (1) that a .venv can been created. | 47 | (1) that a .venv can been created. |
68 | (2) a functional 'rustc' and 'cargo' | 48 | (2) a functional 'rustc' and 'cargo' |
69 | """ | 49 | """ |
70 | self._run("cd %s/guessing-game; python3 -m venv .venv" % self.tc.sdk_dir) | 50 | targetdir = os.path.join(self.tc.sdk_dir, "guessing-game") |
71 | cmd = "cd %s/guessing-game; maturin develop" % self.tc.sdk_dir | 51 | try: |
72 | output = self._run(cmd) | 52 | shutil.rmtree(targetdir) |
53 | except FileNotFoundError: | ||
54 | pass | ||
55 | shutil.copytree( | ||
56 | os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir | ||
57 | ) | ||
58 | |||
59 | self._run("cd %s; python3 -m venv .venv" % targetdir) | ||
60 | output = self._run("cd %s; maturin develop" % targetdir) | ||
73 | self.assertRegex(output, r"🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8") | 61 | self.assertRegex(output, r"🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8") |
74 | self.assertRegex(output, r"🐍 Not using a specific python interpreter") | 62 | self.assertRegex(output, r"🐍 Not using a specific python interpreter") |
75 | self.assertRegex(output, r"📡 Using build options features from pyproject.toml") | 63 | self.assertRegex(output, r"📡 Using build options features from pyproject.toml") |