PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Apache License 2.0
12.43k stars 766 forks source link

Fix windows free-threaded build issues #4690

Closed ngoldbaum closed 2 weeks ago

ngoldbaum commented 2 weeks ago

Fixes #4685.

This fixes a number of issues in the free-threaded build on Windows.

Before, we were linking libpython313.dll but we really wanted libpython313t.dll. This is the correct thing to do on all platforms so I also updated the build config to always look for a dynamic library with the t suffix. This may matter for packaging on Linux distros, depending on how they decide to package the free-threaded build.

It also updates the logic to get sysconfig data from the interpreter at build time on Windows. Before, we always ignored the sysconfigdata because it was never populated, but as of 3.13 this has been fixed, so I only return a blank sysconfig on Python < 3.13.

I also had to account for the fact that Python.h doesn't do #define Py_GIL_DISABLED on windows for the ffi check.

ngoldbaum commented 2 weeks ago

With this the pytests pass on my Windows dev machine. I just need to fix up the clippy warnings and add Windows CI and this should be ready.