Skip to content

Commit 63f2de6

Browse files
ivanbelenkyefimov-mikhailned-deily
authored andcommitted
Synced docs and docstring for sysconfig.get_platform (pythonGH-135530)
(cherry picked from commit 01cc532) Co-authored-by: ivan <[email protected]> Co-authored-by: Mikhail Efimov <[email protected]> Co-authored-by: Ned Deily <[email protected]>
1 parent 2b8ff3c commit 63f2de6

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
@@ -596,18 +596,22 @@ def get_platform():
596596
isn't particularly important.
597597
598598
Examples of returned values:
599-
linux-i586
600-
linux-alpha (?)
601-
solaris-2.6-sun4u
602599
603-
Windows will return one of:
604-
win-amd64 (64-bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
605-
win-arm64 (64-bit Windows on ARM64 (aka AArch64)
606-
win32 (all others - specifically, sys.platform is returned)
607600
608-
For other non-POSIX platforms, currently just returns 'sys.platform'.
601+
Windows:
609602
610-
"""
603+
- win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T)
604+
- win-arm64 (64-bit Windows on ARM64, aka AArch64)
605+
- win32 (all others - specifically, sys.platform is returned)
606+
607+
POSIX based OS:
608+
609+
- linux-x86_64
610+
- macosx-15.5-arm64
611+
- macosx-26.0-universal2 (macOS on Apple Silicon or Intel)
612+
- android-24-arm64_v8a
613+
614+
For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
611615
if os.name == 'nt':
612616
if 'amd64' in sys.version.lower():
613617
return 'win-amd64'

Lib/test/test_sysconfig.py

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

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

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

0 commit comments

Comments
 (0)