diff options
Diffstat (limited to 'meta/lib/oeqa/sdk/cases/maturin.py')
-rw-r--r-- | meta/lib/oeqa/sdk/cases/maturin.py | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py index ea10f568b2..e3e8edc781 100644 --- a/meta/lib/oeqa/sdk/cases/maturin.py +++ b/meta/lib/oeqa/sdk/cases/maturin.py | |||
@@ -8,7 +8,6 @@ import os | |||
8 | import shutil | 8 | import shutil |
9 | import unittest | 9 | import unittest |
10 | 10 | ||
11 | from oeqa.core.utils.path import remove_safe | ||
12 | from oeqa.sdk.case import OESDKTestCase | 11 | from oeqa.sdk.case import OESDKTestCase |
13 | from oeqa.utils.subprocesstweak import errors_have_output | 12 | from oeqa.utils.subprocesstweak import errors_have_output |
14 | 13 | ||
@@ -17,44 +16,24 @@ errors_have_output() | |||
17 | 16 | ||
18 | class MaturinTest(OESDKTestCase): | 17 | class MaturinTest(OESDKTestCase): |
19 | def setUp(self): | 18 | def setUp(self): |
20 | if not ( | 19 | self.ensure_host_package("python3-maturin") |
21 | self.tc.hasHostPackage("nativesdk-python3-maturin") | ||
22 | or self.tc.hasHostPackage("python3-maturin-native") | ||
23 | ): | ||
24 | raise unittest.SkipTest("No python3-maturin package in the SDK") | ||
25 | 20 | ||
26 | def test_maturin_list_python(self): | 21 | def test_maturin_list_python(self): |
27 | 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}")'""") |
28 | py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'") | 23 | executable, version = out.splitlines() |
29 | python_version = "%s.%s" % (py_major.strip(), py_minor.strip()) | ||
30 | cmd = "maturin list-python" | ||
31 | output = self._run(cmd) | ||
32 | self.assertRegex(output, r"^🐍 1 python interpreter found:\n") | ||
33 | self.assertRegex( | ||
34 | output, | ||
35 | r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), | ||
36 | ) | ||
37 | 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) | ||
38 | 31 | ||
39 | class MaturinDevelopTest(OESDKTestCase): | 32 | class MaturinDevelopTest(OESDKTestCase): |
40 | @classmethod | ||
41 | def setUpClass(self): | ||
42 | targetdir = os.path.join(self.tc.sdk_dir, "guessing-game") | ||
43 | try: | ||
44 | shutil.rmtree(targetdir) | ||
45 | except FileNotFoundError: | ||
46 | pass | ||
47 | shutil.copytree( | ||
48 | os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir | ||
49 | ) | ||
50 | |||
51 | def setUp(self): | 33 | def setUp(self): |
52 | machine = self.td.get("MACHINE") | 34 | machine = self.td.get("MACHINE") |
53 | if not ( | 35 | self.ensure_host_package("python3-maturin") |
54 | self.tc.hasHostPackage("nativesdk-python3-maturin") | 36 | |
55 | or self.tc.hasHostPackage("python3-maturin-native") | ||
56 | ): | ||
57 | raise unittest.SkipTest("No python3-maturin package in the SDK") | ||
58 | if not ( | 37 | if not ( |
59 | self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine) | 38 | self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine) |
60 | ): | 39 | ): |
@@ -68,9 +47,17 @@ class MaturinDevelopTest(OESDKTestCase): | |||
68 | (1) that a .venv can been created. | 47 | (1) that a .venv can been created. |
69 | (2) a functional 'rustc' and 'cargo' | 48 | (2) a functional 'rustc' and 'cargo' |
70 | """ | 49 | """ |
71 | 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") |
72 | cmd = "cd %s/guessing-game; maturin develop" % self.tc.sdk_dir | 51 | try: |
73 | 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) | ||
74 | 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") |
75 | self.assertRegex(output, r"🐍 Not using a specific python interpreter") | 62 | self.assertRegex(output, r"🐍 Not using a specific python interpreter") |
76 | self.assertRegex(output, r"📡 Using build options features from pyproject.toml") | 63 | self.assertRegex(output, r"📡 Using build options features from pyproject.toml") |