]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-146541: Allow building the Android testbed for 32-bit targets (GH-146542...
authorMalcolm Smith <smith@chaquo.com>
Sun, 5 Apr 2026 23:47:01 +0000 (00:47 +0100)
committerGitHub <noreply@github.com>
Sun, 5 Apr 2026 23:47:01 +0000 (07:47 +0800)
Allows building the Android testbed for 32-bit targets, adding the target triplets
`arm-linux-androideabi` and `i686-linux-android`.
(cherry picked from commit 848bbe9ff21ae0a3ee412cc25843835ace4f75df)

Co-authored-by: Robert Kirkman <31490854+robertkirkman@users.noreply.github.com>
Android/android.py
Android/testbed/app/build.gradle.kts
Lib/sysconfig/__init__.py
Lib/test/test_sysconfig.py
Misc/NEWS.d/next/Build/2026-03-28-02-48-51.gh-issue-146541.k-zlM6.rst [new file with mode: 0644]

index 79e3631ff2f822ed21125bedeb7a8e2c6e70f096..60d062aa66fce207dc4dc7434db063508e85a807 100755 (executable)
@@ -34,7 +34,12 @@ ENV_SCRIPT = ANDROID_DIR / "android-env.sh"
 TESTBED_DIR = ANDROID_DIR / "testbed"
 CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
 
-HOSTS = ["aarch64-linux-android", "x86_64-linux-android"]
+HOSTS = [
+    "aarch64-linux-android",
+    "arm-linux-androideabi",
+    "i686-linux-android",
+    "x86_64-linux-android",
+]
 APP_ID = "org.python.testbed"
 DECODE_ARGS = ("UTF-8", "backslashreplace")
 
index 53cdc591fa35fd18e96d49216f45247f5cca3d5f..7529fdb8f7852f2e967d58d2697cfbcf74f74881 100644 (file)
@@ -15,6 +15,8 @@ val inSourceTree = (
 
 val KNOWN_ABIS = mapOf(
     "aarch64-linux-android" to "arm64-v8a",
+    "arm-linux-androideabi" to "armeabi-v7a",
+    "i686-linux-android" to "x86",
     "x86_64-linux-android" to "x86_64",
 )
 
index b24dd1dd9c23b9e831955fe2de9d18f4baaded6f..43edebce347cae1336876c682a55c4ba6d2026bf 100644 (file)
@@ -647,12 +647,16 @@ def get_platform():
             # When Python is running on 32-bit ARM Android on a 64-bit ARM kernel,
             # 'os.uname().machine' is 'armv8l'. Such devices run the same userspace
             # code as 'armv7l' devices.
+            # During the build process of the Android testbed when targeting 32-bit ARM,
+            # '_PYTHON_HOST_PLATFORM' is 'arm-linux-androideabi', so 'machine' becomes
+            # 'arm'.
             machine = {
-                "x86_64": "x86_64",
-                "i686": "x86",
                 "aarch64": "arm64_v8a",
+                "arm": "armeabi_v7a",
                 "armv7l": "armeabi_v7a",
                 "armv8l": "armeabi_v7a",
+                "i686": "x86",
+                "x86_64": "x86_64",
             }[machine]
         else:
             # At least on Linux/Intel, 'machine' is the processor --
index 78a55768fce83b915353926a83f2f70ecb025a61..ce17206a3ce70d4bdc53eb4f783c31d054223e3a 100644 (file)
@@ -373,11 +373,12 @@ class TestSysConfig(unittest.TestCase):
         sys.platform = 'android'
         get_config_vars()['ANDROID_API_LEVEL'] = 9
         for machine, abi in {
-            'x86_64': 'x86_64',
-            'i686': 'x86',
             'aarch64': 'arm64_v8a',
+            'arm': 'armeabi_v7a',
             'armv7l': 'armeabi_v7a',
             'armv8l': 'armeabi_v7a',
+            'i686': 'x86',
+            'x86_64': 'x86_64',
         }.items():
             with self.subTest(machine):
                 self._set_uname(('Linux', 'localhost', '3.18.91+',
@@ -586,11 +587,12 @@ class TestSysConfig(unittest.TestCase):
         machine = platform.machine()
         suffix = sysconfig.get_config_var('EXT_SUFFIX')
         expected_triplet = {
-            "x86_64": "x86_64-linux-android",
-            "i686": "i686-linux-android",
             "aarch64": "aarch64-linux-android",
+            "arm": "arm-linux-androideabi",
             "armv7l": "arm-linux-androideabi",
             "armv8l": "arm-linux-androideabi",
+            "i686": "i686-linux-android",
+            "x86_64": "x86_64-linux-android",
         }[machine]
         self.assertTrue(suffix.endswith(f"-{expected_triplet}.so"),
                         f"{machine=}, {suffix=}")
diff --git a/Misc/NEWS.d/next/Build/2026-03-28-02-48-51.gh-issue-146541.k-zlM6.rst b/Misc/NEWS.d/next/Build/2026-03-28-02-48-51.gh-issue-146541.k-zlM6.rst
new file mode 100644 (file)
index 0000000..351071b
--- /dev/null
@@ -0,0 +1 @@
+The Android testbed can now be built for 32-bit ARM and x86 targets.