Skip to content

[BUG] Fail to compile extensions on Windows free-threading non-MSVC #5126

@crusaderky

Description

@crusaderky

setuptools version

setuptools == 80.9.0

Python version

3.13t, 3.14t

OS

Windows

Description

blis uses setuptools to compile Cython extensions with cmake. Due to nuances around the pure-C libraries, it does not use MSVC, but instead it uses new_compiler(plat="nt", compiler="unix").

Compilation fails on 3.13t and 3.14t:

 clang.exe [...] -lpython314 [...]
 LINK : fatal error LNK1181: cannot open input file 'python314.lib'

In some environments which for some reason deploy both python314.lib and python314t.lib, like actions/setup-python, the linking instead succeeds but then the interpreter segfaults on import.

The issue is caused by this code branch, which fails to account for "t" variants of python*.lib:

if not isinstance(self.compiler, MSVCCompiler):
template = "python%d%d"
if self.debug:
template = template + '_d'
pythonlib = template % (
sys.hexversion >> 24,
(sys.hexversion >> 16) & 0xFF,
)
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib]

Expected behavior

On 3.14t clang must be passed -lpython314t instead of -lpython314

Workaround

Subclass build_ext and override the method build_ext.get_libraries to make it return ["python314t"] instead of ["python314"].

How to Reproduce

pip install git+https://github.com/explosion/cython-blis.git@9dbe572cef57b394f97b3114a3e28ec04eb3a39e

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions