@@ -666,34 +666,34 @@ def get_platform():
666666
667667 # Set for cross builds explicitly
668668 if "_PYTHON_HOST_PLATFORM" in os .environ :
669- return os .environ ["_PYTHON_HOST_PLATFORM" ]
670-
671- # Try to distinguish various flavours of Unix
672- osname , host , release , version , machine = os . uname ()
673-
674- # Convert the OS name to lowercase, remove '/' characters, and translate
675- # spaces (for "Power Macintosh")
676- osname = osname . lower (). replace ( '/' , '' )
677- machine = machine . replace (' ' , '_ ' )
678- machine = machine .replace ('/ ' , '- ' )
679-
680- if osname [: 5 ] == "linux" :
681- if sys .platform == "android" :
682- osname = "android"
683- release = get_config_var ("ANDROID_API_LEVEL" )
684-
685- # Wheel tags use the ABI names from Android's own tools.
686- machine = {
687- "x86_64" : "x86_64" ,
688- "i686" : "x86" ,
689- "aarch64" : "arm64_v8a" ,
690- "armv7l" : "armeabi_v7a" ,
691- }[machine ]
692- else :
693- # At least on Linux/Intel, 'machine' is the processor --
694- # i386, etc.
695- # XXX what about Alpha, SPARC, etc?
696- return f"{ osname } -{ machine } "
669+ osname , _ , machine = os .environ ["_PYTHON_HOST_PLATFORM" ]. partition ( '-' )
670+ release = None
671+ else :
672+ # Try to distinguish various flavours of Unix
673+ osname , host , release , version , machine = os . uname ()
674+
675+ # Convert the OS name to lowercase, remove '/' characters, and translate
676+ # spaces (for "Power Macintosh" )
677+ osname = osname . lower (). replace ('/ ' , '' )
678+ machine = machine .replace (' ' , '_ ' )
679+ machine = machine . replace ( '/' , '-' )
680+
681+ if osname == "android" or sys .platform == "android" :
682+ osname = "android"
683+ release = get_config_var ("ANDROID_API_LEVEL" )
684+
685+ # Wheel tags use the ABI names from Android's own tools.
686+ machine = {
687+ "x86_64" : "x86_64" ,
688+ "i686" : "x86" ,
689+ "aarch64" : "arm64_v8a" ,
690+ "armv7l" : "armeabi_v7a" ,
691+ }[machine ]
692+ elif osname == "linux" :
693+ # At least on Linux/Intel, 'machine' is the processor --
694+ # i386, etc.
695+ # XXX what about Alpha, SPARC, etc?
696+ return f"{ osname } -{ machine } "
697697 elif osname [:5 ] == "sunos" :
698698 if release [0 ] >= "5" : # SunOS 5 == Solaris 2
699699 osname = "solaris"
@@ -725,7 +725,7 @@ def get_platform():
725725 get_config_vars (),
726726 osname , release , machine )
727727
728- return f" { osname } - { release } - { machine } "
728+ return '-' . join ( map ( str , filter ( None , ( osname , release , machine ))))
729729
730730
731731def get_python_version ():
0 commit comments