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") 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.