Meson Python introspection runs on the host interpreter, but the target Python (Android) cannot be executed on the build machine. We therefore run host Python and override sysconfig data to emulate the target Android Python environment during Meson introspection.
(self, arch)
| 1431 | return wrapper_path |
| 1432 | |
| 1433 | def get_python_wrapper(self, arch): |
| 1434 | """ |
| 1435 | Meson Python introspection runs on the host interpreter, but the |
| 1436 | target Python (Android) cannot be executed on the build machine. |
| 1437 | |
| 1438 | We therefore run host Python and override sysconfig data to emulate |
| 1439 | the target Android Python environment during Meson introspection. |
| 1440 | """ |
| 1441 | python_recipe = Recipe.get_recipe('python3', self.ctx) |
| 1442 | target_prefix = python_recipe.get_python_root(arch) |
| 1443 | python_file = join(self.ctx.root_dir, 'meson_python.py') |
| 1444 | _arch = { |
| 1445 | "arm64-v8a": ["aarch64"], |
| 1446 | "x86_64": ["x86_64"], |
| 1447 | "armeabi-v7a": ["arm"], |
| 1448 | "x86": ["i686"], |
| 1449 | }[arch.arch][0] |
| 1450 | |
| 1451 | # Real values pulled from android |
| 1452 | # PYTHON_MAJOR_VERSION -> 3 |
| 1453 | # PYTHON_MINOR_VERSION -> 14 |
| 1454 | # PLATFORM_TAG eg -> 'android-24-arm64_v8a' |
| 1455 | # PYTHON_SUFFIX eg -> '.cpython-314-aarch64-linux-android.so' |
| 1456 | |
| 1457 | _p_version = Version(python_recipe.version) |
| 1458 | file_data = f"#!{self.real_hostpython_location}" |
| 1459 | file_data += f"\nTARGET_PYTHON_PREFIX='{target_prefix}'" |
| 1460 | file_data += f"\nPYTHON_MAJOR_VERSION='{_p_version.major}'" |
| 1461 | file_data += f"\nPYTHON_MINOR_VERSION='{_p_version.minor}'" |
| 1462 | file_data += f"\nPLATFORM_TAG='{self.get_wheel_platform_tags(arch.arch, self.ctx)[0]}'" |
| 1463 | file_data += f"\nPYTHON_SUFFIX='.cpython-{_p_version.major}{_p_version.minor}-{_arch}-linux-android.so'" |
| 1464 | |
| 1465 | with open(python_file, "r") as f: |
| 1466 | file_data += "\n" + f.read() |
| 1467 | |
| 1468 | return self.write_wrapper(arch, "python", file_data) |
| 1469 | |
| 1470 | def get_config_wrappers(self, arch, w_type: str): |
| 1471 | wrapper_name = "" |
no test coverage detected