MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / get_host_platform

Function get_host_platform

tools/python-3.11.9-amd64/Lib/distutils/util.py:19–97  ·  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 i

()

Source from the content-addressed store, hash-verified

17from distutils.errors import DistutilsByteCompileError
18
19def get_host_platform():
20 """Return a string that identifies the current platform. This is used mainly to
21 distinguish platform-specific build directories and platform-specific built
22 distributions. Typically includes the OS name and version and the
23 architecture (as supplied by 'os.uname()'), although the exact information
24 included depends on the OS; eg. on Linux, the kernel version isn't
25 particularly important.
26
27 Examples of returned values:
28 linux-i586
29 linux-alpha (?)
30 solaris-2.6-sun4u
31
32 Windows will return one of:
33 win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
34 win32 (all others - specifically, sys.platform is returned)
35
36 For other non-POSIX platforms, currently just returns 'sys.platform'.
37
38 """
39 if os.name == 'nt':
40 if 'amd64' in sys.version.lower():
41 return 'win-amd64'
42 if '(arm)' in sys.version.lower():
43 return 'win-arm32'
44 if '(arm64)' in sys.version.lower():
45 return 'win-arm64'
46 return sys.platform
47
48 # Set for cross builds explicitly
49 if "_PYTHON_HOST_PLATFORM" in os.environ:
50 return os.environ["_PYTHON_HOST_PLATFORM"]
51
52 if os.name != "posix" or not hasattr(os, 'uname'):
53 # XXX what about the architecture? NT is Intel or Alpha,
54 # Mac OS is M68k or PPC, etc.
55 return sys.platform
56
57 # Try to distinguish various flavours of Unix
58
59 (osname, host, release, version, machine) = os.uname()
60
61 # Convert the OS name to lowercase, remove '/' characters, and translate
62 # spaces (for "Power Macintosh")
63 osname = osname.lower().replace('/', '')
64 machine = machine.replace(' ', '_')
65 machine = machine.replace('/', '-')
66
67 if osname[:5] == "linux":
68 # At least on Linux/Intel, 'machine' is the processor --
69 # i386, etc.
70 # XXX what about Alpha, SPARC, etc?
71 return "%s-%s" % (osname, machine)
72 elif osname[:5] == "sunos":
73 if release[0] >= "5": # SunOS 5 == Solaris 2
74 osname = "solaris"
75 release = "%d.%s" % (int(release[0]) - 3, release[2:])
76 # We can't use "platform.architecture()[0]" because a

Callers 1

get_platformFunction · 0.70

Calls 6

aix_platformFunction · 0.90
lowerMethod · 0.45
replaceMethod · 0.45
compileMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected