Windows installer, freethreading and building extension modules

I’m trying to help someone who was trying to build a really basic Cython extension module with the free-threading build on Windows. I think it’s going to hit anyone trying to build an extension module on Windows and not just Cython.

Essentially 3 things go wrong:

  • the installer generates 2 exes, but only one pyconfig.h file (which is for the regular non-freethreading build). This means that when you run python3.13t.exe build_ext --inplace it actually builds without Py_GIL_DISABLED set.
  • However it still generates an extension file: something.cp313t-win_amd64.pyd which is misleadingly named as if it is a correct free-threading extension module. Which then immediately crashes.
  • If I manually edit pyconfig.h to uncomment #define Py_GIL_DISABLED 1 when I get a different error: LINK : fatal error LNK1104: cannot open file 'python313t.lib'. That lib file doesn’t appear to be part of the Windows distribution, and that’s when I get stuck.

Apologies if this is posted in the wrong place - I’m not sure where’s the best place for installer bugs. Happy to file this as a bug report somewhere else if that’s more appropriate.


Bug reports are generally best to go to

You should be able to define this yourself when building (hopefully your build backend allows for preprocessor variables). The multiple pyconfig.h problem is why we skipped an alpha, and this is the workaround, which will probably last until the day when the variable becomes redundant.

It looks like you’re using setuptools. They can start detecting the variable and passing it themselves whenever they like. Unlike the change to having multiple pyconfig.h files, we didn’t feel the need to block releases until they caught up. It’s easy enough to set the variable yourself.

That’s a bug, if you’ve selected the option for the freethreaded binaries. It should include the right libs.

Thanks - I was just unsure if the Windows installer came under the main cpython repo. I’ve filed a bug report for the missing library Windows installer missing free-threading library · Issue #119679 · python/cpython · GitHub.

It sounds like the pyconfig issue will be something that Cython will have to document at least, but I can see there probably aren’t easy solutions.

1 Like


with latest python-3.13.0b2 ( download, windows), I get a fib.cp313t-win_amd64.pyd, but “import fib” still exits miserably … a procedure would be appreciated, if you can build one

There’s two separate issues.

  1. Py_GIL_DISABLED isn’t defined. This is apparently difficult to fix in the Windows distribution and I don’t think a fix is planned. You need to define that macro yourself (e.g. in your script).
  2. The missing library. That has been fixed (but I’m not sure if for beta 2).

If you’re getting a crash then you’re hitting issue 1 so solve that first.

It didn’t work for me … will retry with 3.13.0b3.
Anyway thanks for your efforts to further the free-threading cause

If we don’t know why it isn’t working, you’ll get the same result with b3. Some information about the crash would be a starting point.

Or hopefully someone with native debugging skills will take a look.