33import json
44import os
55import re
6+ import sysconfig
67
78from contextlib import contextmanager
89from copy import deepcopy
1516from poetry .utils .env .script_strings import GET_BASE_PREFIX
1617from poetry .utils .env .script_strings import GET_ENVIRONMENT_INFO
1718from poetry .utils .env .script_strings import GET_PATHS
19+ from poetry .utils .env .script_strings import GET_PLATFORMS
1820from poetry .utils .env .script_strings import GET_SYS_PATH
1921
2022
@@ -54,6 +56,7 @@ def get_supported_tags(self) -> list[Tag]:
5456 python = self .version_info [:3 ]
5557 interpreter_name = self .marker_env ["interpreter_name" ]
5658 interpreter_version = self .marker_env ["interpreter_version" ]
59+ sysconfig_platform = self .marker_env ["sysconfig_platform" ]
5760
5861 if interpreter_name == "pp" :
5962 interpreter = "pp3"
@@ -62,9 +65,28 @@ def get_supported_tags(self) -> list[Tag]:
6265 else :
6366 interpreter = None
6467
68+ # Why using sysconfig.get_platform() and not ...
69+ # ... platform.machine()
70+ # This one is also different for x86_64 Linux and aarch64 Linux,
71+ # but it is the same for a 32 Bit and a 64 Bit Python on Windows!
72+ # ... platform.architecture()
73+ # This one is also different for a 32 Bit and a 64 Bit Python on Windows,
74+ # but it is the same for x86_64 Linux and aarch64 Linux!
75+ platforms = None
76+ if sysconfig_platform != sysconfig .get_platform ():
77+ # Relevant for the following use cases, for example:
78+ # - using a 32 Bit Python on a 64 Bit Windows
79+ # - using an emulated aarch Python on an x86_64 Linux
80+ output = self .run_python_script (GET_PLATFORMS )
81+ platforms = json .loads (output )
82+
6583 return [
66- * (cpython_tags (python ) if interpreter_name == "cp" else generic_tags ()),
67- * compatible_tags (python , interpreter = interpreter ),
84+ * (
85+ cpython_tags (python , platforms = platforms )
86+ if interpreter_name == "cp"
87+ else generic_tags (platforms = platforms )
88+ ),
89+ * compatible_tags (python , interpreter = interpreter , platforms = platforms ),
6890 ]
6991
7092 def get_marker_env (self ) -> dict [str , Any ]:
0 commit comments