@@ -569,6 +569,30 @@ def watchos_ver(system="", release="", model="", is_simulator=False):
569569 return WatchOSVersionInfo (system , release , model , is_simulator )
570570
571571
572+ # A namedtuple for visionOS version information.
573+ VisionOSVersionInfo = collections .namedtuple (
574+ "VisionOSVersionInfo" ,
575+ ["system" , "release" , "model" , "is_simulator" ]
576+ )
577+
578+
579+ def visionos_ver (system = "" , release = "" , model = "" , is_simulator = False ):
580+ """Get visionOS version information, and return it as a namedtuple:
581+ (system, release, model, is_simulator).
582+
583+ If values can't be determined, they are set to values provided as
584+ parameters.
585+ """
586+ if sys .platform == "visionos" :
587+ # TODO: Can the iOS implementation be used here?
588+ import _ios_support
589+ result = _ios_support .get_platform_ios ()
590+ if result is not None :
591+ return VisionOSVersionInfo (* result )
592+
593+ return VisionOSVersionInfo (system , release , model , is_simulator )
594+
595+
572596def _java_getprop (name , default ):
573597 """This private helper is deprecated in 3.13 and will be removed in 3.15"""
574598 from java .lang import System
@@ -768,7 +792,7 @@ def _syscmd_file(target, default=''):
768792 default in case the command should fail.
769793
770794 """
771- if sys .platform in {'dos' , 'win32' , 'win16' , 'ios' , 'tvos' , 'watchos' }:
795+ if sys .platform in {'dos' , 'win32' , 'win16' , 'ios' , 'tvos' , 'watchos' , 'visionos' }:
772796 # XXX Others too ?
773797 return default
774798
@@ -932,7 +956,7 @@ def get_OpenVMS():
932956 csid , cpu_number = vms_lib .getsyi ('SYI$_CPU' , 0 )
933957 return 'Alpha' if cpu_number >= 128 else 'VAX'
934958
935- # On the iOS/tvOS/watchOS simulator, os.uname returns the architecture as
959+ # On the iOS/tvOS/watchOS/visionOS simulator, os.uname returns the architecture as
936960 # uname.machine. On device it returns the model name for some reason; but
937961 # there's only one CPU architecture for devices, so we know the right
938962 # answer.
@@ -951,6 +975,11 @@ def get_watchos():
951975 return os .uname ().machine
952976 return 'arm64_32'
953977
978+ def get_visionos ():
979+ if sys .implementation ._multiarch .endswith ("simulator" ):
980+ return os .uname ().machine
981+ return 'arm64'
982+
954983 def from_subprocess ():
955984 """
956985 Fall back to `uname -p`
@@ -1117,6 +1146,8 @@ def uname():
11171146 system , release , _ , _ = tvos_ver ()
11181147 if sys .platform == 'watchos' :
11191148 system , release , _ , _ = watchos_ver ()
1149+ if sys .platform == 'visionos' :
1150+ system , release , _ , _ = visionos_ver ()
11201151
11211152 vals = system , node , release , version , machine
11221153 # Replace 'unknown' values with the more portable ''
@@ -1410,6 +1441,8 @@ def platform(aliased=False, terse=False):
14101441 system , release , _ , _ = tvos_ver ()
14111442 elif sys .platform == "watchos" :
14121443 system , release , _ , _ = watchos_ver ()
1444+ elif sys .platform == "visionos" :
1445+ system , release , _ , _ = visionos_ver ()
14131446 else :
14141447 macos_release = mac_ver ()[0 ]
14151448 if macos_release :
0 commit comments