From b9895262bde4aa757c30ca644d7431a5c0946065 Mon Sep 17 00:00:00 2001 From: Robert Kirkman Date: Fri, 27 Mar 2026 21:31:46 -0500 Subject: [PATCH 1/2] gh-146541: Allow building the Android testbed for 32-bit targets This allows building the Android testbed for 32-bit targets using the prebuilt 32-bit dependencies that are already available here: https://github.com/beeware/cpython-android-source-deps/releases , adding the target triplets to match them, `arm-linux-androideabi` and `i686-linux-android`. This also adds the `arm` key to the dictionary used to convert the `machine` variable to an Android ABI in `sysconfig.get_platform()`, because when the Android testbed is being cross-compiled, it stores the contents of the first substring of `_PYTHON_HOST_PLATFORM` before the first `-` symbol in the `machine` variable, which the dictionary does not currently handle. --- Android/android.py | 2 +- Android/testbed/app/build.gradle.kts | 2 ++ Lib/sysconfig/__init__.py | 4 ++++ Lib/test/test_sysconfig.py | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Android/android.py b/Android/android.py index 317875ef336e0e..11dda73a7b2efe 100755 --- a/Android/android.py +++ b/Android/android.py @@ -34,7 +34,7 @@ TESTBED_DIR = ANDROID_DIR / "testbed" CROSS_BUILD_DIR = PYTHON_DIR / "cross-build" -HOSTS = ["aarch64-linux-android", "x86_64-linux-android"] +HOSTS = ["aarch64-linux-android", "x86_64-linux-android", "arm-linux-androideabi", "i686-linux-android"] APP_ID = "org.python.testbed" DECODE_ARGS = ("UTF-8", "backslashreplace") diff --git a/Android/testbed/app/build.gradle.kts b/Android/testbed/app/build.gradle.kts index 53cdc591fa35fd..465f6630bdc061 100644 --- a/Android/testbed/app/build.gradle.kts +++ b/Android/testbed/app/build.gradle.kts @@ -16,6 +16,8 @@ val inSourceTree = ( val KNOWN_ABIS = mapOf( "aarch64-linux-android" to "arm64-v8a", "x86_64-linux-android" to "x86_64", + "arm-linux-androideabi" to "armeabi-v7a", + "i686-linux-android" to "x86", ) // Discover prefixes. diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py index 1418293dcbac0b..77ed0fc0981899 100644 --- a/Lib/sysconfig/__init__.py +++ b/Lib/sysconfig/__init__.py @@ -697,12 +697,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", "armv7l": "armeabi_v7a", "armv8l": "armeabi_v7a", + "arm": "armeabi_v7a", }[machine] elif osname == "linux": # At least on Linux/Intel, 'machine' is the processor -- diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 6cd568eb3d0412..5027323801b259 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -376,6 +376,7 @@ def test_get_platform(self): 'aarch64': 'arm64_v8a', 'armv7l': 'armeabi_v7a', 'armv8l': 'armeabi_v7a', + 'arm': 'armeabi_v7a', }.items(): with self.subTest(machine): self._set_uname(('Linux', 'localhost', '3.18.91+', @@ -585,6 +586,7 @@ def test_android_ext_suffix(self): "aarch64": "aarch64-linux-android", "armv7l": "arm-linux-androideabi", "armv8l": "arm-linux-androideabi", + "arm": "arm-linux-androideabi", }[machine] self.assertEndsWith(suffix, f"-{expected_triplet}.so") From 8805c89697037926966648d0d4711fee39ea7fbc Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 02:48:52 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2026-03-28-02-48-51.gh-issue-146541.k-zlM6.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2026-03-28-02-48-51.gh-issue-146541.k-zlM6.rst 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 index 00000000000000..35644b32dfe692 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-03-28-02-48-51.gh-issue-146541.k-zlM6.rst @@ -0,0 +1 @@ +This allows building the Android testbed for 32-bit targets, adding the target triplets to match them, arm-linux-androideabi and i686-linux-android. This also adds the arm key to the dictionary used to convert the machine variable to an Android ABI in sysconfig.get_platform(), because when the Android testbed is being cross-compiled, it stores the contents of the first substring of _PYTHON_HOST_PLATFORM before the first - symbol in the machine variable, which the dictionary did not previously handle.