mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-71052: Change Android's sys.platform
from "linux" to "android"
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
9f983e00ec
commit
872c0714fc
24 changed files with 97 additions and 81 deletions
|
@ -1367,47 +1367,42 @@ always available.
|
||||||
|
|
||||||
.. data:: platform
|
.. data:: platform
|
||||||
|
|
||||||
This string contains a platform identifier that can be used to append
|
A string containing a platform identifier. Known values are:
|
||||||
platform-specific components to :data:`sys.path`, for instance.
|
|
||||||
|
|
||||||
For Unix systems, except on Linux and AIX, this is the lowercased OS name as
|
================ ===========================
|
||||||
returned by ``uname -s`` with the first part of the version as returned by
|
System ``platform`` value
|
||||||
|
================ ===========================
|
||||||
|
AIX ``'aix'``
|
||||||
|
Android ``'android'``
|
||||||
|
Emscripten ``'emscripten'``
|
||||||
|
iOS ``'ios'``
|
||||||
|
Linux ``'linux'``
|
||||||
|
macOS ``'darwin'``
|
||||||
|
Windows ``'win32'``
|
||||||
|
Windows/Cygwin ``'cygwin'``
|
||||||
|
WASI ``'wasi'``
|
||||||
|
================ ===========================
|
||||||
|
|
||||||
|
On Unix systems not listed in the table, the value is the lowercased OS name
|
||||||
|
as returned by ``uname -s``, with the first part of the version as returned by
|
||||||
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
|
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
|
||||||
when Python was built*. Unless you want to test for a specific system
|
when Python was built*. Unless you want to test for a specific system
|
||||||
version, it is therefore recommended to use the following idiom::
|
version, it is therefore recommended to use the following idiom::
|
||||||
|
|
||||||
if sys.platform.startswith('freebsd'):
|
if sys.platform.startswith('freebsd'):
|
||||||
# FreeBSD-specific code here...
|
# FreeBSD-specific code here...
|
||||||
elif sys.platform.startswith('linux'):
|
|
||||||
# Linux-specific code here...
|
|
||||||
elif sys.platform.startswith('aix'):
|
|
||||||
# AIX-specific code here...
|
|
||||||
|
|
||||||
For other systems, the values are:
|
|
||||||
|
|
||||||
================ ===========================
|
|
||||||
System ``platform`` value
|
|
||||||
================ ===========================
|
|
||||||
AIX ``'aix'``
|
|
||||||
Emscripten ``'emscripten'``
|
|
||||||
Linux ``'linux'``
|
|
||||||
WASI ``'wasi'``
|
|
||||||
Windows ``'win32'``
|
|
||||||
Windows/Cygwin ``'cygwin'``
|
|
||||||
macOS ``'darwin'``
|
|
||||||
================ ===========================
|
|
||||||
|
|
||||||
.. versionchanged:: 3.3
|
.. versionchanged:: 3.3
|
||||||
On Linux, :data:`sys.platform` doesn't contain the major version anymore.
|
On Linux, :data:`sys.platform` doesn't contain the major version anymore.
|
||||||
It is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``. Since
|
It is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``.
|
||||||
older Python versions include the version number, it is recommended to
|
|
||||||
always use the ``startswith`` idiom presented above.
|
|
||||||
|
|
||||||
.. versionchanged:: 3.8
|
.. versionchanged:: 3.8
|
||||||
On AIX, :data:`sys.platform` doesn't contain the major version anymore.
|
On AIX, :data:`sys.platform` doesn't contain the major version anymore.
|
||||||
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``. Since
|
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``.
|
||||||
older Python versions include the version number, it is recommended to
|
|
||||||
always use the ``startswith`` idiom presented above.
|
.. versionchanged:: 3.13
|
||||||
|
On Android, :data:`sys.platform` now returns ``'android'`` rather than
|
||||||
|
``'linux'``.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|
|
@ -468,7 +468,7 @@ pydll = LibraryLoader(PyDLL)
|
||||||
|
|
||||||
if _os.name == "nt":
|
if _os.name == "nt":
|
||||||
pythonapi = PyDLL("python dll", None, _sys.dllhandle)
|
pythonapi = PyDLL("python dll", None, _sys.dllhandle)
|
||||||
elif hasattr(_sys, "getandroidapilevel"):
|
elif _sys.platform == "android":
|
||||||
pythonapi = PyDLL("libpython%d.%d.so" % _sys.version_info[:2])
|
pythonapi = PyDLL("libpython%d.%d.so" % _sys.version_info[:2])
|
||||||
elif _sys.platform == "cygwin":
|
elif _sys.platform == "cygwin":
|
||||||
pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
|
pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
|
||||||
|
|
|
@ -102,11 +102,7 @@ def log_to_stderr(level=None):
|
||||||
# Abstract socket support
|
# Abstract socket support
|
||||||
|
|
||||||
def _platform_supports_abstract_sockets():
|
def _platform_supports_abstract_sockets():
|
||||||
if sys.platform == "linux":
|
return sys.platform in ("linux", "android")
|
||||||
return True
|
|
||||||
if hasattr(sys, 'getandroidapilevel'):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def is_abstract_socket_namespace(address):
|
def is_abstract_socket_namespace(address):
|
||||||
|
|
|
@ -47,7 +47,8 @@ else:
|
||||||
COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
|
COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
|
||||||
# This should never be removed, see rationale in:
|
# This should never be removed, see rationale in:
|
||||||
# https://bugs.python.org/issue43743#msg393429
|
# https://bugs.python.org/issue43743#msg393429
|
||||||
_USE_CP_SENDFILE = hasattr(os, "sendfile") and sys.platform.startswith("linux")
|
_USE_CP_SENDFILE = (hasattr(os, "sendfile")
|
||||||
|
and sys.platform.startswith(("linux", "android")))
|
||||||
_HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS
|
_HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS
|
||||||
|
|
||||||
# CMD defaults in Windows 10
|
# CMD defaults in Windows 10
|
||||||
|
|
|
@ -520,7 +520,7 @@ MS_WINDOWS = (sys.platform == 'win32')
|
||||||
# Is not actually used in tests, but is kept for compatibility.
|
# Is not actually used in tests, but is kept for compatibility.
|
||||||
is_jython = sys.platform.startswith('java')
|
is_jython = sys.platform.startswith('java')
|
||||||
|
|
||||||
is_android = hasattr(sys, 'getandroidapilevel')
|
is_android = sys.platform == "android"
|
||||||
|
|
||||||
if sys.platform not in {"win32", "vxworks", "ios", "tvos", "watchos"}:
|
if sys.platform not in {"win32", "vxworks", "ios", "tvos", "watchos"}:
|
||||||
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
|
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
|
||||||
|
|
|
@ -612,7 +612,7 @@ class FakePath:
|
||||||
def fd_count():
|
def fd_count():
|
||||||
"""Count the number of open file descriptors.
|
"""Count the number of open file descriptors.
|
||||||
"""
|
"""
|
||||||
if sys.platform.startswith(('linux', 'freebsd', 'emscripten')):
|
if sys.platform.startswith(('linux', 'android', 'freebsd', 'emscripten')):
|
||||||
fd_path = "/proc/self/fd"
|
fd_path = "/proc/self/fd"
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
fd_path = "/dev/fd"
|
fd_path = "/dev/fd"
|
||||||
|
|
|
@ -480,7 +480,8 @@ class SubprocessMixin:
|
||||||
self.assertEqual(output, None)
|
self.assertEqual(output, None)
|
||||||
self.assertEqual(exitcode, 0)
|
self.assertEqual(exitcode, 0)
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform != 'linux', "Don't have /dev/stdin")
|
@unittest.skipIf(sys.platform not in ('linux', 'android'),
|
||||||
|
"Don't have /dev/stdin")
|
||||||
def test_devstdin_input(self):
|
def test_devstdin_input(self):
|
||||||
|
|
||||||
async def devstdin_input(message):
|
async def devstdin_input(message):
|
||||||
|
|
|
@ -26,17 +26,16 @@ EXPECT_COERCION_IN_DEFAULT_LOCALE = True
|
||||||
TARGET_LOCALES = ["C.UTF-8", "C.utf8", "UTF-8"]
|
TARGET_LOCALES = ["C.UTF-8", "C.utf8", "UTF-8"]
|
||||||
|
|
||||||
# Apply some platform dependent overrides
|
# Apply some platform dependent overrides
|
||||||
if sys.platform.startswith("linux"):
|
if sys.platform == "android":
|
||||||
if support.is_android:
|
# Android defaults to using UTF-8 for all system interfaces
|
||||||
# Android defaults to using UTF-8 for all system interfaces
|
EXPECTED_C_LOCALE_STREAM_ENCODING = "utf-8"
|
||||||
EXPECTED_C_LOCALE_STREAM_ENCODING = "utf-8"
|
EXPECTED_C_LOCALE_FS_ENCODING = "utf-8"
|
||||||
EXPECTED_C_LOCALE_FS_ENCODING = "utf-8"
|
elif sys.platform.startswith("linux"):
|
||||||
else:
|
# Linux distros typically alias the POSIX locale directly to the C
|
||||||
# Linux distros typically alias the POSIX locale directly to the C
|
# locale.
|
||||||
# locale.
|
# TODO: Once https://bugs.python.org/issue30672 is addressed, we'll be
|
||||||
# TODO: Once https://bugs.python.org/issue30672 is addressed, we'll be
|
# able to check this case unconditionally
|
||||||
# able to check this case unconditionally
|
EXPECTED_C_LOCALE_EQUIVALENTS.append("POSIX")
|
||||||
EXPECTED_C_LOCALE_EQUIVALENTS.append("POSIX")
|
|
||||||
elif sys.platform.startswith("aix"):
|
elif sys.platform.startswith("aix"):
|
||||||
# AIX uses iso8859-1 in the C locale, other *nix platforms use ASCII
|
# AIX uses iso8859-1 in the C locale, other *nix platforms use ASCII
|
||||||
EXPECTED_C_LOCALE_STREAM_ENCODING = "iso8859-1"
|
EXPECTED_C_LOCALE_STREAM_ENCODING = "iso8859-1"
|
||||||
|
|
|
@ -129,8 +129,8 @@ class TestFcntl(unittest.TestCase):
|
||||||
fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK)
|
fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK)
|
||||||
|
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
any(platform.machine().startswith(name) for name in {"arm", "aarch"})
|
platform.machine().startswith(("arm", "aarch"))
|
||||||
and platform.system() in {"Linux", "Android"},
|
and platform.system() in ("Linux", "Android"),
|
||||||
"ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT")
|
"ARM Linux returns EINVAL for F_NOTIFY DN_MULTISHOT")
|
||||||
def test_fcntl_64_bit(self):
|
def test_fcntl_64_bit(self):
|
||||||
# Issue #1309352: fcntl shouldn't fail when the third arg fits in a
|
# Issue #1309352: fcntl shouldn't fail when the third arg fits in a
|
||||||
|
|
|
@ -603,7 +603,7 @@ class HandlerTest(BaseTest):
|
||||||
def test_builtin_handlers(self):
|
def test_builtin_handlers(self):
|
||||||
# We can't actually *use* too many handlers in the tests,
|
# We can't actually *use* too many handlers in the tests,
|
||||||
# but we can try instantiating them with various options
|
# but we can try instantiating them with various options
|
||||||
if sys.platform in ('linux', 'darwin'):
|
if sys.platform in ('linux', 'android', 'darwin'):
|
||||||
for existing in (True, False):
|
for existing in (True, False):
|
||||||
fn = make_temp_file()
|
fn = make_temp_file()
|
||||||
if not existing:
|
if not existing:
|
||||||
|
@ -667,7 +667,7 @@ class HandlerTest(BaseTest):
|
||||||
(logging.handlers.RotatingFileHandler, (pfn, 'a')),
|
(logging.handlers.RotatingFileHandler, (pfn, 'a')),
|
||||||
(logging.handlers.TimedRotatingFileHandler, (pfn, 'h')),
|
(logging.handlers.TimedRotatingFileHandler, (pfn, 'h')),
|
||||||
)
|
)
|
||||||
if sys.platform in ('linux', 'darwin'):
|
if sys.platform in ('linux', 'android', 'darwin'):
|
||||||
cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),)
|
cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),)
|
||||||
for cls, args in cases:
|
for cls, args in cases:
|
||||||
h = cls(*args, encoding="utf-8")
|
h = cls(*args, encoding="utf-8")
|
||||||
|
|
|
@ -837,7 +837,7 @@ class MmapTests(unittest.TestCase):
|
||||||
mm.write(b'python')
|
mm.write(b'python')
|
||||||
result = mm.flush()
|
result = mm.flush()
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith(('linux', 'android')):
|
||||||
# 'offset' must be a multiple of mmap.PAGESIZE on Linux.
|
# 'offset' must be a multiple of mmap.PAGESIZE on Linux.
|
||||||
# See bpo-34754 for details.
|
# See bpo-34754 for details.
|
||||||
self.assertRaises(OSError, mm.flush, 1, len(b'python'))
|
self.assertRaises(OSError, mm.flush, 1, len(b'python'))
|
||||||
|
|
|
@ -3533,9 +3533,8 @@ class ProgramPriorityTests(unittest.TestCase):
|
||||||
class TestSendfile(unittest.IsolatedAsyncioTestCase):
|
class TestSendfile(unittest.IsolatedAsyncioTestCase):
|
||||||
|
|
||||||
DATA = b"12345abcde" * 16 * 1024 # 160 KiB
|
DATA = b"12345abcde" * 16 * 1024 # 160 KiB
|
||||||
SUPPORT_HEADERS_TRAILERS = not sys.platform.startswith("linux") and \
|
SUPPORT_HEADERS_TRAILERS = (
|
||||||
not sys.platform.startswith("solaris") and \
|
not sys.platform.startswith(("linux", "android", "solaris", "sunos")))
|
||||||
not sys.platform.startswith("sunos")
|
|
||||||
requires_headers_trailers = unittest.skipUnless(SUPPORT_HEADERS_TRAILERS,
|
requires_headers_trailers = unittest.skipUnless(SUPPORT_HEADERS_TRAILERS,
|
||||||
'requires headers and trailers support')
|
'requires headers and trailers support')
|
||||||
requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
|
requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
|
||||||
|
@ -5256,7 +5255,7 @@ class ForkTests(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
assert_python_ok("-c", code, PYTHONMALLOC="malloc_debug")
|
assert_python_ok("-c", code, PYTHONMALLOC="malloc_debug")
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform in ("linux", "darwin"),
|
@unittest.skipUnless(sys.platform in ("linux", "android", "darwin"),
|
||||||
"Only Linux and macOS detect this today.")
|
"Only Linux and macOS detect this today.")
|
||||||
def test_fork_warns_when_non_python_thread_exists(self):
|
def test_fork_warns_when_non_python_thread_exists(self):
|
||||||
code = """if 1:
|
code = """if 1:
|
||||||
|
|
|
@ -138,7 +138,7 @@ class ResourceTest(unittest.TestCase):
|
||||||
self.assertIsInstance(pagesize, int)
|
self.assertIsInstance(pagesize, int)
|
||||||
self.assertGreaterEqual(pagesize, 0)
|
self.assertGreaterEqual(pagesize, 0)
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == 'linux', 'test requires Linux')
|
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'Linux only')
|
||||||
def test_linux_constants(self):
|
def test_linux_constants(self):
|
||||||
for attr in ['MSGQUEUE', 'NICE', 'RTPRIO', 'RTTIME', 'SIGPENDING']:
|
for attr in ['MSGQUEUE', 'NICE', 'RTPRIO', 'RTTIME', 'SIGPENDING']:
|
||||||
with contextlib.suppress(AttributeError):
|
with contextlib.suppress(AttributeError):
|
||||||
|
|
|
@ -1199,8 +1199,8 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
# I've ordered this by protocols that have both a tcp and udp
|
# I've ordered this by protocols that have both a tcp and udp
|
||||||
# protocol, at least for modern Linuxes.
|
# protocol, at least for modern Linuxes.
|
||||||
if (
|
if (
|
||||||
sys.platform.startswith(('freebsd', 'netbsd', 'gnukfreebsd'))
|
sys.platform.startswith(
|
||||||
or sys.platform == 'linux'
|
('linux', 'android', 'freebsd', 'netbsd', 'gnukfreebsd'))
|
||||||
or is_apple
|
or is_apple
|
||||||
):
|
):
|
||||||
# avoid the 'echo' service on this platform, as there is an
|
# avoid the 'echo' service on this platform, as there is an
|
||||||
|
@ -1218,8 +1218,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
raise OSError
|
raise OSError
|
||||||
# Try same call with optional protocol omitted
|
# Try same call with optional protocol omitted
|
||||||
# Issue #26936: Android getservbyname() was broken before API 23.
|
# Issue #26936: Android getservbyname() was broken before API 23.
|
||||||
if (not hasattr(sys, 'getandroidapilevel') or
|
if (not support.is_android) or sys.getandroidapilevel() >= 23:
|
||||||
sys.getandroidapilevel() >= 23):
|
|
||||||
port2 = socket.getservbyname(service)
|
port2 = socket.getservbyname(service)
|
||||||
eq(port, port2)
|
eq(port, port2)
|
||||||
# Try udp, but don't barf if it doesn't exist
|
# Try udp, but don't barf if it doesn't exist
|
||||||
|
@ -1577,8 +1576,7 @@ class GeneralModuleTests(unittest.TestCase):
|
||||||
# port can be a string service name such as "http", a numeric
|
# port can be a string service name such as "http", a numeric
|
||||||
# port number or None
|
# port number or None
|
||||||
# Issue #26936: Android getaddrinfo() was broken before API level 23.
|
# Issue #26936: Android getaddrinfo() was broken before API level 23.
|
||||||
if (not hasattr(sys, 'getandroidapilevel') or
|
if (not support.is_android) or sys.getandroidapilevel() >= 23:
|
||||||
sys.getandroidapilevel() >= 23):
|
|
||||||
socket.getaddrinfo(HOST, "http")
|
socket.getaddrinfo(HOST, "http")
|
||||||
socket.getaddrinfo(HOST, 80)
|
socket.getaddrinfo(HOST, 80)
|
||||||
socket.getaddrinfo(HOST, None)
|
socket.getaddrinfo(HOST, None)
|
||||||
|
@ -3196,7 +3194,7 @@ class SendmsgStreamTests(SendmsgTests):
|
||||||
# Linux supports MSG_DONTWAIT when sending, but in general, it
|
# Linux supports MSG_DONTWAIT when sending, but in general, it
|
||||||
# only works when receiving. Could add other platforms if they
|
# only works when receiving. Could add other platforms if they
|
||||||
# support it too.
|
# support it too.
|
||||||
@skipWithClientIf(sys.platform not in {"linux"},
|
@skipWithClientIf(sys.platform not in {"linux", "android"},
|
||||||
"MSG_DONTWAIT not known to work on this platform when "
|
"MSG_DONTWAIT not known to work on this platform when "
|
||||||
"sending")
|
"sending")
|
||||||
def testSendmsgDontWait(self):
|
def testSendmsgDontWait(self):
|
||||||
|
@ -5634,7 +5632,7 @@ class TestExceptions(unittest.TestCase):
|
||||||
sock.setblocking(False)
|
sock.setblocking(False)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == 'linux', 'Linux specific test')
|
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'Linux specific test')
|
||||||
class TestLinuxAbstractNamespace(unittest.TestCase):
|
class TestLinuxAbstractNamespace(unittest.TestCase):
|
||||||
|
|
||||||
UNIX_PATH_MAX = 108
|
UNIX_PATH_MAX = 108
|
||||||
|
@ -5759,7 +5757,8 @@ class TestUnixDomain(unittest.TestCase):
|
||||||
self.addCleanup(os_helper.unlink, path)
|
self.addCleanup(os_helper.unlink, path)
|
||||||
self.assertEqual(self.sock.getsockname(), path)
|
self.assertEqual(self.sock.getsockname(), path)
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform == 'linux', 'Linux specific test')
|
@unittest.skipIf(sys.platform in ('linux', 'android'),
|
||||||
|
'Linux behavior is tested by TestLinuxAbstractNamespace')
|
||||||
def testEmptyAddress(self):
|
def testEmptyAddress(self):
|
||||||
# Test that binding empty address fails.
|
# Test that binding empty address fails.
|
||||||
self.assertRaises(OSError, self.sock.bind, "")
|
self.assertRaises(OSError, self.sock.bind, "")
|
||||||
|
|
|
@ -4914,7 +4914,7 @@ class TestPreHandshakeClose(unittest.TestCase):
|
||||||
pass # closed, protocol error, etc.
|
pass # closed, protocol error, etc.
|
||||||
|
|
||||||
def non_linux_skip_if_other_okay_error(self, err):
|
def non_linux_skip_if_other_okay_error(self, err):
|
||||||
if sys.platform == "linux":
|
if sys.platform in ("linux", "android"):
|
||||||
return # Expect the full test setup to always work on Linux.
|
return # Expect the full test setup to always work on Linux.
|
||||||
if (isinstance(err, ConnectionResetError) or
|
if (isinstance(err, ConnectionResetError) or
|
||||||
(isinstance(err, OSError) and err.errno == errno.EINVAL) or
|
(isinstance(err, OSError) and err.errno == errno.EINVAL) or
|
||||||
|
|
|
@ -668,7 +668,7 @@ class SysModuleTest(unittest.TestCase):
|
||||||
self.assertEqual(len(info), 3)
|
self.assertEqual(len(info), 3)
|
||||||
self.assertIn(info.name, ('nt', 'pthread', 'pthread-stubs', 'solaris', None))
|
self.assertIn(info.name, ('nt', 'pthread', 'pthread-stubs', 'solaris', None))
|
||||||
self.assertIn(info.lock, ('semaphore', 'mutex+cond', None))
|
self.assertIn(info.lock, ('semaphore', 'mutex+cond', None))
|
||||||
if sys.platform.startswith(("linux", "freebsd")):
|
if sys.platform.startswith(("linux", "android", "freebsd")):
|
||||||
self.assertEqual(info.name, "pthread")
|
self.assertEqual(info.name, "pthread")
|
||||||
elif sys.platform == "win32":
|
elif sys.platform == "win32":
|
||||||
self.assertEqual(info.name, "nt")
|
self.assertEqual(info.name, "nt")
|
||||||
|
@ -1101,8 +1101,7 @@ class SysModuleTest(unittest.TestCase):
|
||||||
self.assertEqual(stdout.rstrip(), b"")
|
self.assertEqual(stdout.rstrip(), b"")
|
||||||
self.assertEqual(stderr.rstrip(), b"")
|
self.assertEqual(stderr.rstrip(), b"")
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(sys, 'getandroidapilevel'),
|
@unittest.skipUnless(sys.platform == "android", "Android only")
|
||||||
'need sys.getandroidapilevel()')
|
|
||||||
def test_getandroidapilevel(self):
|
def test_getandroidapilevel(self):
|
||||||
level = sys.getandroidapilevel()
|
level = sys.getandroidapilevel()
|
||||||
self.assertIsInstance(level, int)
|
self.assertIsInstance(level, int)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -516,12 +518,9 @@ class TestSysConfig(unittest.TestCase):
|
||||||
vars = sysconfig.get_config_vars()
|
vars = sysconfig.get_config_vars()
|
||||||
self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
|
self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == 'linux' and
|
@unittest.skipUnless(sys.platform == 'linux', 'Linux-specific test')
|
||||||
hasattr(sys.implementation, '_multiarch'),
|
def test_linux_ext_suffix(self):
|
||||||
'multiarch-specific test')
|
|
||||||
def test_triplet_in_ext_suffix(self):
|
|
||||||
ctypes = import_module('ctypes')
|
ctypes = import_module('ctypes')
|
||||||
import platform, re
|
|
||||||
machine = platform.machine()
|
machine = platform.machine()
|
||||||
suffix = sysconfig.get_config_var('EXT_SUFFIX')
|
suffix = sysconfig.get_config_var('EXT_SUFFIX')
|
||||||
if re.match('(aarch64|arm|mips|ppc|powerpc|s390|sparc)', machine):
|
if re.match('(aarch64|arm|mips|ppc|powerpc|s390|sparc)', machine):
|
||||||
|
@ -534,6 +533,19 @@ class TestSysConfig(unittest.TestCase):
|
||||||
self.assertTrue(suffix.endswith(expected_suffixes),
|
self.assertTrue(suffix.endswith(expected_suffixes),
|
||||||
f'unexpected suffix {suffix!r}')
|
f'unexpected suffix {suffix!r}')
|
||||||
|
|
||||||
|
@unittest.skipUnless(sys.platform == 'android', 'Android-specific test')
|
||||||
|
def test_android_ext_suffix(self):
|
||||||
|
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",
|
||||||
|
"armv7l": "arm-linux-androideabi",
|
||||||
|
}[machine]
|
||||||
|
self.assertTrue(suffix.endswith(f"-{expected_triplet}.so"),
|
||||||
|
f"{machine=}, {suffix=}")
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == 'darwin', 'OS X-specific test')
|
@unittest.skipUnless(sys.platform == 'darwin', 'OS X-specific test')
|
||||||
def test_osx_ext_suffix(self):
|
def test_osx_ext_suffix(self):
|
||||||
suffix = sysconfig.get_config_var('EXT_SUFFIX')
|
suffix = sysconfig.get_config_var('EXT_SUFFIX')
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ class GNUReadTest(LongnameTest, ReadTest, unittest.TestCase):
|
||||||
#
|
#
|
||||||
# The function returns False if page size is larger than 4 KiB.
|
# The function returns False if page size is larger than 4 KiB.
|
||||||
# For example, ppc64 uses pages of 64 KiB.
|
# For example, ppc64 uses pages of 64 KiB.
|
||||||
if sys.platform.startswith("linux"):
|
if sys.platform.startswith(("linux", "android")):
|
||||||
# Linux evidentially has 512 byte st_blocks units.
|
# Linux evidentially has 512 byte st_blocks units.
|
||||||
name = os.path.join(TEMPDIR, "sparse-test")
|
name = os.path.join(TEMPDIR, "sparse-test")
|
||||||
with open(name, "wb") as fobj:
|
with open(name, "wb") as fobj:
|
||||||
|
|
|
@ -511,7 +511,7 @@ class TimeTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_thread_time(self):
|
def test_thread_time(self):
|
||||||
if not hasattr(time, 'thread_time'):
|
if not hasattr(time, 'thread_time'):
|
||||||
if sys.platform.startswith(('linux', 'win')):
|
if sys.platform.startswith(('linux', 'android', 'win')):
|
||||||
self.fail("time.thread_time() should be available on %r"
|
self.fail("time.thread_time() should be available on %r"
|
||||||
% (sys.platform,))
|
% (sys.platform,))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -62,7 +62,7 @@ else:
|
||||||
import platform
|
import platform
|
||||||
_platform_system = platform.system()
|
_platform_system = platform.system()
|
||||||
_AIX = _platform_system == 'AIX'
|
_AIX = _platform_system == 'AIX'
|
||||||
_LINUX = _platform_system == 'Linux'
|
_LINUX = _platform_system in ('Linux', 'Android')
|
||||||
|
|
||||||
_MAC_DELIM = b':'
|
_MAC_DELIM = b':'
|
||||||
_MAC_OMITS_LEADING_ZEROES = False
|
_MAC_OMITS_LEADING_ZEROES = False
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Change Android's :data:`sys.platform` from ``"linux"`` to ``"android"``.
|
|
@ -12,8 +12,20 @@
|
||||||
#undef powerpc
|
#undef powerpc
|
||||||
#undef sparc
|
#undef sparc
|
||||||
#undef unix
|
#undef unix
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
# Android is not a multiarch system.
|
# if defined(__x86_64__)
|
||||||
|
PLATFORM_TRIPLET=x86_64-linux-android
|
||||||
|
# elif defined(__i386__)
|
||||||
|
PLATFORM_TRIPLET=i686-linux-android
|
||||||
|
# elif defined(__aarch64__)
|
||||||
|
PLATFORM_TRIPLET=aarch64-linux-android
|
||||||
|
# elif defined(__arm__)
|
||||||
|
PLATFORM_TRIPLET=arm-linux-androideabi
|
||||||
|
# else
|
||||||
|
# error unknown Android platform
|
||||||
|
# endif
|
||||||
|
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
/*
|
/*
|
||||||
* BEGIN of Linux block
|
* BEGIN of Linux block
|
||||||
|
|
1
configure
generated
vendored
1
configure
generated
vendored
|
@ -4071,6 +4071,7 @@ then
|
||||||
|
|
||||||
case $MACHDEP in
|
case $MACHDEP in
|
||||||
aix*) MACHDEP="aix";;
|
aix*) MACHDEP="aix";;
|
||||||
|
linux-android*) MACHDEP="android";;
|
||||||
linux*) MACHDEP="linux";;
|
linux*) MACHDEP="linux";;
|
||||||
cygwin*) MACHDEP="cygwin";;
|
cygwin*) MACHDEP="cygwin";;
|
||||||
darwin*) MACHDEP="darwin";;
|
darwin*) MACHDEP="darwin";;
|
||||||
|
|
|
@ -362,6 +362,7 @@ then
|
||||||
|
|
||||||
case $MACHDEP in
|
case $MACHDEP in
|
||||||
aix*) MACHDEP="aix";;
|
aix*) MACHDEP="aix";;
|
||||||
|
linux-android*) MACHDEP="android";;
|
||||||
linux*) MACHDEP="linux";;
|
linux*) MACHDEP="linux";;
|
||||||
cygwin*) MACHDEP="cygwin";;
|
cygwin*) MACHDEP="cygwin";;
|
||||||
darwin*) MACHDEP="darwin";;
|
darwin*) MACHDEP="darwin";;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue