pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

[BUG]: Unknown CMake command "python3_add_library" with Python 3.14t (Free Threaded)

Open Laky-64 opened this issue 4 months ago • 2 comments

Required prerequisites

  • [x] Make sure you've read the documentation. Your issue may be addressed there.
  • [x] Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
  • [x] Consider asking first in the Gitter chat room or in a Discussion.

What version (or hash if on master) of pybind11 are you using?

stable (3.0.0)

Problem description

Hi!

I'm trying to use pybind11 with Python 3.14t (Free Threaded), using the official manylinux Docker images, but I'm running into the following issue:

Unknown CMake command "python3_add_library"

It works fine with all other Python versions, including the standard Python 3.14, but not with the free-threaded edition.

In my CMakeLists.txt I'm finding Python like this:

find_package(Python3 REQUIRED COMPONENTS Interpreter)

And I'm passing the Python executable from my setup.py, as seen here: https://github.com/pytgcalls/ntgcalls/blob/master/setup.py#L79

Any idea why this issue happens specifically with Python 3.14t?

Thanks!

Is this a regression? Put the last known working version here if it is.

Not a regression

Laky-64 avatar Aug 21 '25 15:08 Laky-64

That's the wrong variable. If you are using FindPython3, you need to pass Python3_EXECUTABLE. Also, you have to include the Development.Module component, not just the Interpreter component. Though if possible, I'd recommend using our support for FindPython; if you use that, you can set set(PYBIND11_FINDPYTHON ON) to ensure you only have modern (Python_*) variables instead of PYTHON_* variables present.

henryiii avatar Aug 21 '25 20:08 henryiii

That's the wrong variable. If you are using FindPython3, you need to pass Python3_EXECUTABLE. Also, you have to include the Development.Module component, not just the Interpreter component. Though if possible, I'd recommend using our support for FindPython; if you use that, you can set set(PYBIND11_FINDPYTHON ON) to ensure you only have modern (Python_*) variables instead of PYTHON_* variables present.

Oh well, but if I try to set up Development.Module it starts saying that libraries not exists even for python3.9+ (That currently they works)

Laky-64 avatar Aug 24 '25 16:08 Laky-64