2929_32_BIT_INTERPRETER = struct .calcsize ('P' ) == 4
3030
3131
32- def get_interpreter_tag () -> str :
33- name = sys .implementation .name
32+ def get_interpreter_tag (build_details : Optional [dict ] = None ) -> str :
33+ if build_details is None :
34+ name = sys .implementation .name
35+ version = sys .version_info
36+ else :
37+ name = build_details ['implementation' ]['name' ]
38+ _v = build_details ['implementation' ]['version' ]
39+ version = (_v ['major' ], _v ['minor' ])
3440 name = INTERPRETERS .get (name , name )
35- version = sys .version_info
3641 return f'{ name } { version [0 ]} { version [1 ]} '
3742
3843
@@ -53,7 +58,12 @@ def _get_cpython_abi() -> str:
5358 return f'cp{ version [0 ]} { version [1 ]} { debug } { pymalloc } '
5459
5560
56- def get_abi_tag () -> str :
61+ def get_abi_tag (build_details : Optional [dict ] = None ) -> str :
62+ if build_details is not None :
63+ ext_suffix = build_details ['abi' ]['extension_suffix' ]
64+ else :
65+ ext_suffix = sysconfig .get_config_var ('EXT_SUFFIX' )
66+
5767 # The best solution to obtain the Python ABI is to parse the
5868 # $SOABI or $EXT_SUFFIX sysconfig variables as defined in PEP-314.
5969
@@ -62,7 +72,7 @@ def get_abi_tag() -> str:
6272 # See https://foss.heptapod.net/pypy/pypy/-/issues/3816 and
6373 # https://github.com/pypa/packaging/pull/607.
6474 try :
65- empty , abi , ext = str (sysconfig . get_config_var ( 'EXT_SUFFIX' ) ).split ('.' )
75+ empty , abi , ext = str (ext_suffix ).split ('.' )
6676 except ValueError as exc :
6777 # CPython <= 3.8.7 on Windows does not implement PEP3149 and
6878 # uses '.pyd' as $EXT_SUFFIX, which does not allow to extract
@@ -178,8 +188,8 @@ def _get_ios_platform_tag() -> str:
178188 return f'ios_{ version [0 ]} _{ version [1 ]} _{ multiarch } '
179189
180190
181- def get_platform_tag () -> str :
182- platform = sysconfig .get_platform ()
191+ def get_platform_tag (build_details : Optional [ dict ] = None ) -> str :
192+ platform = build_details [ 'platform' ] if build_details is not None else sysconfig .get_platform ()
183193 if platform .startswith ('macosx' ):
184194 return _get_macosx_platform_tag ()
185195 if platform .startswith ('ios' ):
@@ -194,10 +204,10 @@ def get_platform_tag() -> str:
194204
195205
196206class Tag :
197- def __init__ (self , interpreter : Optional [str ] = None , abi : Optional [str ] = None , platform : Optional [str ] = None ):
198- self .interpreter = interpreter or get_interpreter_tag ()
199- self .abi = abi or get_abi_tag ()
200- self .platform = platform or get_platform_tag ()
207+ def __init__ (self , interpreter : Optional [str ] = None , abi : Optional [str ] = None , platform : Optional [str ] = None , build_details : Optional [ dict ] = None ):
208+ self .interpreter = interpreter or get_interpreter_tag (build_details )
209+ self .abi = abi or get_abi_tag (build_details )
210+ self .platform = platform or get_platform_tag (build_details )
201211
202212 def __str__ (self ) -> str :
203213 return f'{ self .interpreter } -{ self .abi } -{ self .platform } '
0 commit comments