Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Android/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap at 80 columns, and keep the list in alphabetical order.

APP_ID = "org.python.testbed"
DECODE_ARGS = ("UTF-8", "backslashreplace")

Expand Down
2 changes: 2 additions & 0 deletions Android/testbed/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use alphabetical order.

)

// Discover prefixes.
Expand Down
4 changes: 4 additions & 0 deletions Lib/sysconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+',
Expand Down Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excessive detail for a release note.

Suggested change
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.
The Android testbed can now be built for 32-bit ARM and x86 targets.

Loading