diff --git a/distutils/command/build_ext.py b/distutils/command/build_ext.py index ec45b440..6d9e85bd 100644 --- a/distutils/command/build_ext.py +++ b/distutils/command/build_ext.py @@ -770,13 +770,14 @@ def get_libraries(self, ext: Extension) -> list[str]: # noqa: C901 from .._msvccompiler import MSVCCompiler if not isinstance(self.compiler, MSVCCompiler): - template = "python%d%d" - if self.debug: - template = template + '_d' - pythonlib = template % ( + pythonlib = "python%d%d" % ( sys.hexversion >> 24, (sys.hexversion >> 16) & 0xFF, ) + if is_freethreaded(): + pythonlib += 't' + if self.debug: + pythonlib += '_d' # don't extend ext.libraries, it may be shared with other # extensions, it is a reference to the original list return ext.libraries + [pythonlib]