Skip to content

Commit 01cc532

Browse files
ivanbelenkyefimov-mikhailned-deily
authored
Synced docs and docstring for sysconfig.get_platform (#135530)
Co-authored-by: Mikhail Efimov <[email protected]> Co-authored-by: Ned Deily <[email protected]>
1 parent b9dbf6a commit 01cc532

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

Doc/library/sysconfig.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,19 @@ Other functions
382382

383383
Examples of returned values:
384384

385-
- linux-i586
386-
- linux-alpha (?)
387-
- solaris-2.6-sun4u
388385

389-
Windows will return one of:
386+
Windows:
390387

391388
- win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T)
392389
- win-arm64 (64-bit Windows on ARM64, aka AArch64)
393390
- win32 (all others - specifically, sys.platform is returned)
394391

395-
macOS can return:
392+
POSIX based OS:
396393

397-
- macosx-10.6-ppc
398-
- macosx-10.4-ppc64
399-
- macosx-10.3-i386
400-
- macosx-10.4-fat
394+
- linux-x86_64
395+
- macosx-15.5-arm64
396+
- macosx-26.0-universal2 (macOS on Apple Silicon or Intel)
397+
- android-24-arm64_v8a
401398

402399
For other non-POSIX platforms, currently just returns :data:`sys.platform`.
403400

Lib/sysconfig/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,18 +645,22 @@ def get_platform():
645645
isn't particularly important.
646646
647647
Examples of returned values:
648-
linux-i586
649-
linux-alpha (?)
650-
solaris-2.6-sun4u
651648
652-
Windows will return one of:
653-
win-amd64 (64-bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
654-
win-arm64 (64-bit Windows on ARM64 (aka AArch64)
655-
win32 (all others - specifically, sys.platform is returned)
656649
657-
For other non-POSIX platforms, currently just returns 'sys.platform'.
650+
Windows:
658651
659-
"""
652+
- win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T)
653+
- win-arm64 (64-bit Windows on ARM64, aka AArch64)
654+
- win32 (all others - specifically, sys.platform is returned)
655+
656+
POSIX based OS:
657+
658+
- linux-x86_64
659+
- macosx-15.5-arm64
660+
- macosx-26.0-universal2 (macOS on Apple Silicon or Intel)
661+
- android-24-arm64_v8a
662+
663+
For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
660664
if os.name == 'nt':
661665
if 'amd64' in sys.version.lower():
662666
return 'win-amd64'

Lib/test/test_sysconfig.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ def test_get_platform(self):
352352

353353
self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch)
354354

355+
for macver in range(11, 16):
356+
_osx_support._remove_original_values(get_config_vars())
357+
get_config_vars()['CFLAGS'] = ('-fno-strict-overflow -Wsign-compare -Wunreachable-code'
358+
'-arch arm64 -fno-common -dynamic -DNDEBUG -g -O3 -Wall')
359+
get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = f"{macver}.0"
360+
self.assertEqual(get_platform(), 'macosx-%d.0-arm64' % macver)
361+
355362
# linux debian sarge
356363
os.name = 'posix'
357364
sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) '

0 commit comments

Comments
 (0)