You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sysconfig.get_platform() could return wrong value because sys.version is truncated #145410
As visible, there is no amd64 in sys.version, because it is truncated. This causes problem when installing native package using pip because cp314-cp314-amd64 is not in the list of supported tags. Instead, the supported tags list become
changed the title [-]sysconfig.get_platform() could returns wrong value because sys.version is truncated[/-][+]sysconfig.get_platform() could return wrong value because sys.version is truncated[/+]on Mar 2, 2026
__clang_version__
Defined to a string that captures the Clang marketing version, including the Subversion tag or revision number, e.g., “1.5 (trunk 102332)”.
#define_Py_COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
I think for future proofing, it is better for the sysconfig module not to depend on sys.version because it is fragile. The plaform module seems to be a better choice.
diff --git a/__init__.py b/__init__.py
index 2ecbff2..c612fd4 100644
--- a/__init__.py+++ b/__init__.py@@ -1,5 +1,6 @@
"""Access to Python's configuration information."""
+import _sysconfig
import os
import sys
import threading
@@ -667,12 +668,15 @@ def get_platform():
For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
if os.name == 'nt':
- if 'amd64' in sys.version.lower():+ platform_tag = _sysconfig.config_vars()['SOABI'].split('-', 1)[-1]+ if platform_tag == 'win_amd64':
return 'win-amd64'
- if '(arm)' in sys.version.lower():+ if platform_tag == 'win_arm32':
return 'win-arm32'
- if '(arm64)' in sys.version.lower():+ if platform_tag == 'win_arm64':
return 'win-arm64'
+ if platform_tag == 'win32':+ return 'win32'
return sys.platform
The Android buildbot also truncates the Clang version in sys.version: 3.15.0a7+ (heads/main-dirty:b5a27bdcf03, Mar 26 2026, 10:04:01) [Clang 18.0.4 (https://android.googlesource.com/toolchain/llvm-project d8003a456.
I fixed the initial issue "sysconfig.get_platform() could return wrong value because sys.version is truncated" with the change b9d4318. I close the issue.
Activity
[-]sysconfig.get_platform() could returns wrong value because sys.version is truncated[/-][+]sysconfig.get_platform() could return wrong value because sys.version is truncated[/+]char101 commentedon Mar 2, 2026
With regard to clang, in
getcompiler.cWhere
__clang_version__is documented as:I think a safer implementation would be
encukou commentedon Mar 2, 2026
This looks like an artifact of
clangbeing untested & unsupported on Windows.Does the full
__clang_version__include the string"amd64"?char101 commentedon Mar 2, 2026
It contains
AMD64, as defined inPC/pyconfig.h, but will be truncated if__clang_version__is long.cpython/PC/pyconfig.h
Line 161 in 201d251
I think for future proofing, it is better for the
sysconfigmodule not to depend onsys.versionbecause it is fragile. Theplaformmodule seems to be a better choice.encukou commentedon Mar 2, 2026
I also wouldn't be against increasing the limits in
getversion.c.zooba commentedon Mar 2, 2026
sysconfigshould rely on_sysconfigif it needs access to something known at compile time.chris-eibl commentedon Mar 8, 2026
Both suggestions seem fine to me, too.
encukou commentedon Mar 18, 2026
@char101, do you want to make a PR?
char101 commentedon Mar 18, 2026
No, I prefer not to make a one line PR, I think the maintainer can do it faster.
char101 commentedon Mar 18, 2026
I would propose this possible change though.
where
SOABIis defined asand the list of
PYD_PLATFORM_TAGarepythongh-145410: Add _sysconfig.get_platform() function
pythongh-145410: Add _sysconfig.get_platform() function
vstinner commentedon Mar 18, 2026
I wrote #146145 to add
_sysconfig.get_platform().gh-145410: Add _sysconfig.get_platform() function (#146145)
vstinner commentedon Mar 26, 2026
The Android buildbot also truncates the Clang version in
sys.version:3.15.0a7+ (heads/main-dirty:b5a27bdcf03, Mar 26 2026, 10:04:01) [Clang 18.0.4 (https://android.googlesource.com/toolchain/llvm-project d8003a456.pythongh-145410: Add _sysconfig.get_platform() function (python#146145)
vstinner commentedon Apr 30, 2026
I fixed the initial issue "sysconfig.get_platform() could return wrong value because sys.version is truncated" with the change b9d4318. I close the issue.