@@ -576,6 +576,30 @@ def watchos_ver(system="", release="", model="", is_simulator=False):
576576 return WatchOSVersionInfo (system , release , model , is_simulator )
577577
578578
579+ # A namedtuple for visionOS version information.
580+ VisionOSVersionInfo = collections .namedtuple (
581+ "VisionOSVersionInfo" ,
582+ ["system" , "release" , "model" , "is_simulator" ]
583+ )
584+
585+
586+ def visionos_ver (system = "" , release = "" , model = "" , is_simulator = False ):
587+ """Get visionOS version information, and return it as a namedtuple:
588+ (system, release, model, is_simulator).
589+
590+ If values can't be determined, they are set to values provided as
591+ parameters.
592+ """
593+ if sys .platform == "visionos" :
594+ # TODO: Can the iOS implementation be used here?
595+ import _ios_support
596+ result = _ios_support .get_platform_ios ()
597+ if result is not None :
598+ return VisionOSVersionInfo (* result )
599+
600+ return VisionOSVersionInfo (system , release , model , is_simulator )
601+
602+
579603def _java_getprop (name , default ):
580604 """This private helper is deprecated in 3.13 and will be removed in 3.15"""
581605 from java .lang import System
@@ -775,7 +799,7 @@ def _syscmd_file(target, default=''):
775799 default in case the command should fail.
776800
777801 """
778- if sys .platform in {'dos' , 'win32' , 'win16' , 'ios' , 'tvos' , 'watchos' }:
802+ if sys .platform in {'dos' , 'win32' , 'win16' , 'ios' , 'tvos' , 'watchos' , 'visionos' }:
779803 # XXX Others too ?
780804 return default
781805
@@ -939,7 +963,7 @@ def get_OpenVMS():
939963 csid , cpu_number = vms_lib .getsyi ('SYI$_CPU' , 0 )
940964 return 'Alpha' if cpu_number >= 128 else 'VAX'
941965
942- # On the iOS/tvOS/watchOS simulator, os.uname returns the architecture as
966+ # On the iOS/tvOS/watchOS/visionOS simulator, os.uname returns the architecture as
943967 # uname.machine. On device it returns the model name for some reason; but
944968 # there's only one CPU architecture for devices, so we know the right
945969 # answer.
@@ -958,6 +982,11 @@ def get_watchos():
958982 return os .uname ().machine
959983 return 'arm64_32'
960984
985+ def get_visionos ():
986+ if sys .implementation ._multiarch .endswith ("simulator" ):
987+ return os .uname ().machine
988+ return 'arm64'
989+
961990 def from_subprocess ():
962991 """
963992 Fall back to `uname -p`
@@ -1124,6 +1153,8 @@ def uname():
11241153 system , release , _ , _ = tvos_ver ()
11251154 if sys .platform == 'watchos' :
11261155 system , release , _ , _ = watchos_ver ()
1156+ if sys .platform == 'visionos' :
1157+ system , release , _ , _ = visionos_ver ()
11271158
11281159 vals = system , node , release , version , machine
11291160 # Replace 'unknown' values with the more portable ''
@@ -1417,6 +1448,8 @@ def platform(aliased=False, terse=False):
14171448 system , release , _ , _ = tvos_ver ()
14181449 elif sys .platform == "watchos" :
14191450 system , release , _ , _ = watchos_ver ()
1451+ elif sys .platform == "visionos" :
1452+ system , release , _ , _ = visionos_ver ()
14201453 else :
14211454 macos_release = mac_ver ()[0 ]
14221455 if macos_release :
0 commit comments