mirror of https://github.com/python/cpython
gh-116622: Android sysconfig updates (#118352)
This commit is contained in:
parent
6d12f4469c
commit
75955110a6
|
@ -61,6 +61,12 @@ done
|
||||||
export CFLAGS=""
|
export CFLAGS=""
|
||||||
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment"
|
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment"
|
||||||
|
|
||||||
|
# Unlike Linux, Android does not implicitly use a dlopened library to resolve
|
||||||
|
# relocations in subsequently-loaded libraries, even if RTLD_GLOBAL is used
|
||||||
|
# (https://github.com/android/ndk/issues/1244). So any library that fails to
|
||||||
|
# build with this flag, would also fail to load at runtime.
|
||||||
|
LDFLAGS="$LDFLAGS -Wl,--no-undefined"
|
||||||
|
|
||||||
# Many packages get away with omitting -lm on Linux, but Android is stricter.
|
# Many packages get away with omitting -lm on Linux, but Android is stricter.
|
||||||
LDFLAGS="$LDFLAGS -lm"
|
LDFLAGS="$LDFLAGS -lm"
|
||||||
|
|
||||||
|
|
|
@ -601,10 +601,22 @@ def get_platform():
|
||||||
machine = machine.replace('/', '-')
|
machine = machine.replace('/', '-')
|
||||||
|
|
||||||
if osname[:5] == "linux":
|
if osname[:5] == "linux":
|
||||||
# At least on Linux/Intel, 'machine' is the processor --
|
if sys.platform == "android":
|
||||||
# i386, etc.
|
osname = "android"
|
||||||
# XXX what about Alpha, SPARC, etc?
|
release = get_config_var("ANDROID_API_LEVEL")
|
||||||
return f"{osname}-{machine}"
|
|
||||||
|
# Wheel tags use the ABI names from Android's own tools.
|
||||||
|
machine = {
|
||||||
|
"x86_64": "x86_64",
|
||||||
|
"i686": "x86",
|
||||||
|
"aarch64": "arm64_v8a",
|
||||||
|
"armv7l": "armeabi_v7a",
|
||||||
|
}[machine]
|
||||||
|
else:
|
||||||
|
# At least on Linux/Intel, 'machine' is the processor --
|
||||||
|
# i386, etc.
|
||||||
|
# XXX what about Alpha, SPARC, etc?
|
||||||
|
return f"{osname}-{machine}"
|
||||||
elif osname[:5] == "sunos":
|
elif osname[:5] == "sunos":
|
||||||
if release[0] >= "5": # SunOS 5 == Solaris 2
|
if release[0] >= "5": # SunOS 5 == Solaris 2
|
||||||
osname = "solaris"
|
osname = "solaris"
|
||||||
|
|
|
@ -232,6 +232,11 @@ class TestSysConfig(unittest.TestCase):
|
||||||
self.assertTrue(cvars)
|
self.assertTrue(cvars)
|
||||||
|
|
||||||
def test_get_platform(self):
|
def test_get_platform(self):
|
||||||
|
# Check the actual platform returns something reasonable.
|
||||||
|
actual_platform = get_platform()
|
||||||
|
self.assertIsInstance(actual_platform, str)
|
||||||
|
self.assertTrue(actual_platform)
|
||||||
|
|
||||||
# windows XP, 32bits
|
# windows XP, 32bits
|
||||||
os.name = 'nt'
|
os.name = 'nt'
|
||||||
sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
|
sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
|
||||||
|
@ -347,6 +352,21 @@ class TestSysConfig(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(get_platform(), 'linux-i686')
|
self.assertEqual(get_platform(), 'linux-i686')
|
||||||
|
|
||||||
|
# Android
|
||||||
|
os.name = 'posix'
|
||||||
|
sys.platform = 'android'
|
||||||
|
get_config_vars()['ANDROID_API_LEVEL'] = 9
|
||||||
|
for machine, abi in {
|
||||||
|
'x86_64': 'x86_64',
|
||||||
|
'i686': 'x86',
|
||||||
|
'aarch64': 'arm64_v8a',
|
||||||
|
'armv7l': 'armeabi_v7a',
|
||||||
|
}.items():
|
||||||
|
with self.subTest(machine):
|
||||||
|
self._set_uname(('Linux', 'localhost', '3.18.91+',
|
||||||
|
'#1 Tue Jan 9 20:35:43 UTC 2018', machine))
|
||||||
|
self.assertEqual(get_platform(), f'android-9-{abi}')
|
||||||
|
|
||||||
# XXX more platforms to tests here
|
# XXX more platforms to tests here
|
||||||
|
|
||||||
@unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds")
|
@unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds")
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
On Android, :any:`sysconfig.get_platform` now returns the format specified
|
||||||
|
by :pep:`738`.
|
|
@ -7018,8 +7018,13 @@ case $host/$ac_cv_cc_name in #(
|
||||||
PY_SUPPORT_TIER=3 ;; #(
|
PY_SUPPORT_TIER=3 ;; #(
|
||||||
aarch64-apple-ios*/clang) :
|
aarch64-apple-ios*/clang) :
|
||||||
PY_SUPPORT_TIER=3 ;; #(
|
PY_SUPPORT_TIER=3 ;; #(
|
||||||
|
aarch64-*-linux-android/clang) :
|
||||||
|
PY_SUPPORT_TIER=3 ;; #(
|
||||||
|
x86_64-*-linux-android/clang) :
|
||||||
|
PY_SUPPORT_TIER=3 ;; #(
|
||||||
*) :
|
*) :
|
||||||
PY_SUPPORT_TIER=0
|
|
||||||
|
PY_SUPPORT_TIER=0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -1148,6 +1148,9 @@ AS_CASE([$host/$ac_cv_cc_name],
|
||||||
[x86_64-*-freebsd*/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64
|
[x86_64-*-freebsd*/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64
|
||||||
[aarch64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64
|
[aarch64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64
|
||||||
[aarch64-apple-ios*/clang], [PY_SUPPORT_TIER=3], dnl iOS on ARM64
|
[aarch64-apple-ios*/clang], [PY_SUPPORT_TIER=3], dnl iOS on ARM64
|
||||||
|
[aarch64-*-linux-android/clang], [PY_SUPPORT_TIER=3], dnl Android on ARM64
|
||||||
|
[x86_64-*-linux-android/clang], [PY_SUPPORT_TIER=3], dnl Android on AMD64
|
||||||
|
|
||||||
[PY_SUPPORT_TIER=0]
|
[PY_SUPPORT_TIER=0]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue