Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
760751b
Mark a concurrency test as requiring fork.
freakboy3742 Mar 16, 2024
b41f9a4
Lower the marshalling stack depth for iOS.
freakboy3742 Mar 16, 2024
0f3e9bc
Add iOS webbrowser support.
freakboy3742 Mar 19, 2024
1a9d965
Updates to site and sysconfig modules for iOS support.
freakboy3742 Mar 19, 2024
c7fe185
Update platform module to provide ios_ver.
freakboy3742 Mar 19, 2024
732c4da
Add changenote.
freakboy3742 Mar 19, 2024
97a081d
Correct some consistency issues.
freakboy3742 Mar 19, 2024
95c367d
Modify testios Makefile target to output failures once.
freakboy3742 Mar 19, 2024
3d6d875
Avoid calling iOS APIs on tvOS/watchOS.
freakboy3742 Mar 19, 2024
d12cfa0
Add a record for the new stdlib module.
freakboy3742 Mar 20, 2024
95d11fb
Add protection against running platform.ios_ver on macOS/Linux, which…
freakboy3742 Mar 20, 2024
48f4c1a
Improve markup in the description of ios_ver()
freakboy3742 Mar 20, 2024
f584d29
Use a namedtuple for ios_ver().
freakboy3742 Mar 20, 2024
9515f75
Ensure the minimum iOS version is used in sysconfig.get_platform()
freakboy3742 Mar 20, 2024
cf0b5ff
Apply suggestions from code review
freakboy3742 Mar 21, 2024
96aa042
Correct the documentation of ios_ver()
freakboy3742 Mar 22, 2024
24b3662
Clarified some discrepancies in the platform module.
freakboy3742 Mar 22, 2024
a4e09c9
Simplify getpath handling.
freakboy3742 Mar 22, 2024
41a3c1a
Modify webbrowser module to use _ios_support as a helper.
freakboy3742 Mar 22, 2024
84ba760
Simplify sysconfig schemes for iOS.
freakboy3742 Mar 22, 2024
4194849
Apply suggestions from code review
freakboy3742 Mar 24, 2024
9a91933
More documentation tweaks.
freakboy3742 Mar 24, 2024
e6550b7
Add protection for missing ctypes to webbrowser module.
freakboy3742 Mar 24, 2024
8654376
Simplifications and clarifications to sysconfig.
freakboy3742 Mar 25, 2024
7a4dcaf
Merge branch 'main' into ios-platform-changes
freakboy3742 Mar 25, 2024
4451326
Correct the naming of the IPHONEOS_DEPLOYMENT_TARGET variable.
freakboy3742 Mar 25, 2024
4386a7a
Added clarifying comment around IPHONEOS_DEPLOYMENT_TARGET
freakboy3742 Mar 25, 2024
c1a1f0b
Merge branch 'main' into ios-platform-changes
freakboy3742 Mar 27, 2024
61559ac
Removed the hard-coded development team.
freakboy3742 Mar 27, 2024
abc2034
Account for some testing edge cases picked up in review.
freakboy3742 Mar 27, 2024
096078a
Disable --with-ensurepip for iOS.
freakboy3742 Mar 27, 2024
44bbf79
Merge branch 'main' into ios-platform-changes
freakboy3742 Mar 27, 2024
7419002
Correct merge of test_platform.
freakboy3742 Mar 27, 2024
c121d5f
Always display iOS test output.
freakboy3742 Mar 28, 2024
1ac4b26
Make test suite resilient to the absence of ctypes.
freakboy3742 Mar 28, 2024
857a0c3
Make webbrowser skip resilient across platforms.
freakboy3742 Mar 28, 2024
aa65dc2
Account for ABI suffix in header directory
ned-deily Mar 28, 2024
61e51ff
test_refcount_errors requires subprocess
ned-deily Mar 28, 2024
2ee4aba
Merge branch 'main' into ios-platform-changes
ned-deily Mar 28, 2024
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
Prev Previous commit
Next Next commit
Clarified some discrepancies in the platform module.
  • Loading branch information
freakboy3742 committed Mar 22, 2024
commit 24b36625023c541b7d31a7211a43bc28d0ad72b5
5 changes: 5 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ process and user.
:func:`socket.gethostname` or even
``socket.gethostbyaddr(socket.gethostname())``.

On macOS, iOS and Android, this returns the *kernel* name and version (i.e.,
``'Darwin'`` on macOS and iOS; ``'Linux'`` on Android), not the user-facing
operating system name. :func:`platform.uname()` can be used to get the
user-facing operating system name on iOS and Android.

.. availability:: Unix.

.. versionchanged:: 3.3
Expand Down
4 changes: 4 additions & 0 deletions Doc/library/platform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ Cross Platform
Returns the system/OS name, such as ``'Linux'``, ``'Darwin'``, ``'Java'``,
``'Windows'``. An empty string is returned if the value cannot be determined.

On iOS, this returns the OS name (i.e, ``'iOS``` or ``'iPadOS'``), rather than
the kernel name (``'Darwin'``).

.. function:: system_alias(system, release, version)

Expand All @@ -161,6 +163,8 @@ Cross Platform
Returns the system's release version, e.g. ``'#3 on degas'``. An empty string is
returned if the value cannot be determined.

On iOS, this is the iOS version, not the Darwin kernel version. To obtain
the Darwin kernel version, use :func:`os.uname()`.

.. function:: uname()

Expand Down
29 changes: 15 additions & 14 deletions Lib/_ios_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
from ctypes import cdll, c_void_p, c_char_p, util
except ImportError:
# ctypes is an optional module. If it's not present, we're limited in what
# we can tell about the system, but we don't want to prevent the platform
# module from working.
# we can tell about the system, but we don't want to prevent the module
# from working.
print("ctypes isn't available; iOS system calls will not be available")
objc = None
else:
# ctypes is available. Load the ObjC library, and wrap the objc_getClass,
# sel_registerName and objc_msgSend methods
objc = cdll.LoadLibrary(util.find_library("objc"))
if objc._name:
objc.objc_getClass.restype = c_void_p
objc.objc_getClass.argtypes = [c_char_p]
objc.sel_registerName.restype = c_void_p
objc.sel_registerName.argtypes = [c_char_p]
# The calls to objc_msgSend all have no arguments; but the return types
# vary with the specific call.
objc.objc_msgSend.argtypes = [c_void_p, c_void_p]
else:
# sel_registerName methods
lib = util.find_library("objc")
if lib is None:
# Failed to load the objc library
objc = None
raise RuntimeError("ObjC runtime library couldn't be loaded")

objc = cdll.LoadLibrary(lib)
objc.objc_getClass.restype = c_void_p
objc.objc_getClass.argtypes = [c_char_p]
objc.sel_registerName.restype = c_void_p
objc.sel_registerName.argtypes = [c_char_p]


def get_platform_ios():
Expand All @@ -33,6 +32,8 @@ def get_platform_ios():

# Most of the methods return ObjC objects
objc.objc_msgSend.restype = c_void_p
# All the methods used have no arguments.
objc.objc_msgSend.argtypes = [c_void_p, c_void_p]

# Equivalent of:
# device = [UIDevice currentDevice]
Expand Down
7 changes: 4 additions & 3 deletions Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,9 @@ def get_OpenVMS():
csid, cpu_number = vms_lib.getsyi('SYI$_CPU', 0)
return 'Alpha' if cpu_number >= 128 else 'VAX'

# On iOS, os.uname returns the architecture as uname.machine. On device it
# doesn't; but there's only one CPU architecture on device.
# On the iOS simulator, os.uname returns the architecture as uname.machine.
# On device it returns the model name for some reason; but there's only one
# CPU architecture for iOS devices, so we know the right answer.
def get_ios():
if sys.implementation._multiarch.endswith("simulator"):
return os.uname().machine
Expand Down Expand Up @@ -1005,7 +1006,7 @@ def uname():

# Normalize responses on iOS
if sys.platform == 'ios':
system, release, machine, _ = ios_ver()
system, release, _, _ = ios_ver()

vals = system, node, release, version, machine
# Replace 'unknown' values with the more portable ''
Expand Down
11 changes: 11 additions & 0 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def test_uname(self):
self.assertEqual(res[-1], res.processor)
self.assertEqual(len(res), 6)

if sys.platform == "ios":
self.assertIn(res.system, {"iOS", "iPadOS"})
self.assertIn(res.release, platform.ios_ver().release)

@unittest.skipUnless(sys.platform.startswith('win'), "windows only test")
def test_uname_win32_without_wmi(self):
def raises_oserror(*a):
Expand Down Expand Up @@ -451,6 +455,13 @@ def test_ios_ver(self):
self.assertEqual(result.model, "")
self.assertFalse(result.is_simulator)

# Check the fallback values can be overridden by arguments
override = platform.ios_ver("Foo", "Bar", "Whiz", True)
self.assertEqual(override.system, "Foo")
self.assertEqual(override.release, "Bar")
self.assertEqual(override.model, "Whiz")
self.assertTrue(override.is_simulator)

@unittest.skipIf(support.is_emscripten, "Does not apply to Emscripten")
def test_libc_ver(self):
# check that libc_ver(executable) doesn't raise an exception
Expand Down