Skip to content

Synced docs and docstring for sysconfig.get_platform #135530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 5 additions & 9 deletions Doc/library/sysconfig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,22 +382,18 @@ Other functions

Examples of returned values:

- linux-i586
- linux-alpha (?)
- solaris-2.6-sun4u

Windows will return one of:
Windows:

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

macOS can return:
POSIX based OS:

- macosx-10.6-ppc
- macosx-10.4-ppc64
- macosx-10.3-i386
- macosx-10.4-fat
- linux-x86_64
- macosx-15.5-arm64
- android-24-arm64_v8a

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

Expand Down
21 changes: 12 additions & 9 deletions Lib/sysconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,18 +639,21 @@ def get_platform():
isn't particularly important.

Examples of returned values:
linux-i586
linux-alpha (?)
solaris-2.6-sun4u

Windows will return one of:
win-amd64 (64-bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
win-arm64 (64-bit Windows on ARM64 (aka AArch64)
win32 (all others - specifically, sys.platform is returned)

For other non-POSIX platforms, currently just returns 'sys.platform'.
Windows:

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

POSIX based OS:

- linux-x86_64
- macosx-15.5-arm64
- android-24-arm64_v8a

For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
if os.name == 'nt':
if 'amd64' in sys.version.lower():
return 'win-amd64'
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ def test_get_platform(self):

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

for macver in range(11, 16):
_osx_support._remove_original_values(get_config_vars())
get_config_vars()['CFLAGS'] = ('-fno-strict-overflow -Wsign-compare -Wunreachable-code'
'-arch arm64 -fno-common -dynamic -DNDEBUG -g -O3 -Wall')
get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = f"{macver}.0"
self.assertEqual(get_platform(), 'macosx-%d.0-arm64' % macver)

# linux debian sarge
os.name = 'posix'
sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) '
Expand Down
Loading