MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_platform

Function get_platform

Lib/sysconfig/__init__.py:643–743  ·  view source on GitHub ↗

Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact

()

Source from the content-addressed store, hash-verified

641
642
643def get_platform():
644 """Return a string that identifies the current platform.
645
646 This is used mainly to distinguish platform-specific build directories and
647 platform-specific built distributions. Typically includes the OS name and
648 version and the architecture (as supplied by 'os.uname()'), although the
649 exact information included depends on the OS; on Linux, the kernel version
650 isn't particularly important.
651
652 Examples of returned values:
653
654
655 Windows:
656
657 - win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T)
658 - win-arm64 (64-bit Windows on ARM64, aka AArch64)
659 - win32 (all others - specifically, sys.platform is returned)
660
661 POSIX based OS:
662
663 - linux-x86_64
664 - macosx-15.5-arm64
665 - macosx-26.0-universal2 (macOS on Apple Silicon or Intel)
666 - android-24-arm64_v8a
667
668 For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
669 if os.name == 'nt':
670 if 'amd64' in sys.version.lower():
671 return 'win-amd64'
672 if '(arm)' in sys.version.lower():
673 return 'win-arm32'
674 if '(arm64)' in sys.version.lower():
675 return 'win-arm64'
676 return sys.platform
677
678 if os.name != "posix" or not hasattr(os, 'uname'):
679 # XXX what about the architecture? NT is Intel or Alpha
680 return sys.platform
681
682 # Set for cross builds explicitly
683 if "_PYTHON_HOST_PLATFORM" in os.environ:
684 osname, _, machine = os.environ["_PYTHON_HOST_PLATFORM"].partition('-')
685 release = None
686 else:
687 # Try to distinguish various flavours of Unix
688 osname, host, release, version, machine = os.uname()
689
690 # Convert the OS name to lowercase, remove '/' characters, and translate
691 # spaces (for "Power Macintosh")
692 osname = osname.lower().replace('/', '')
693 machine = machine.replace(' ', '_')
694 machine = machine.replace('/', '-')
695
696 if osname == "android" or sys.platform == "android":
697 osname = "android"
698 release = get_config_var("ANDROID_API_LEVEL")
699
700 # Wheel tags use the ABI names from Android's own tools.

Callers 3

_get_pybuilddirFunction · 0.90
_mainFunction · 0.90
test_get_platformMethod · 0.90

Calls 13

aix_platformFunction · 0.90
hasattrFunction · 0.85
get_config_varFunction · 0.85
get_config_varsFunction · 0.85
filterFunction · 0.85
lowerMethod · 0.45
partitionMethod · 0.45
replaceMethod · 0.45
compileMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45
getMethod · 0.45

Tested by 1

test_get_platformMethod · 0.72