FindPython does not find Development directory


I have some CMake code that tries to find Python with the following lines

    _set_default( arg_VERSION  3.9 )
    find_package( Python ${arg_VERSION} COMPONENTS Interpreter Development)

However, it fails to find Development directory, but it works if I put manually the path to it after.
Here is the content of the variables after calling it:

Python_VERSION: 3.9.18
Python_INCLUDE_DIRS: /usr/include/python3.9
Python_Development_FOUND: FALSE
Python_Interpreter_FOUND: TRUE
Python_EXECUTABLE /usr/bin/python3.9

I’m on:

  • AlmaLinux 9.4,
  • CMake 3.27.7,
  • Python 3.9.18, with python-devel installed with the same version.

Python executable is in /usr/bin/python3.9
Python include directory in /usr/include/python3.9,
Python library directory in /usr/lib64/python3.9/.

Is it a known issue? Do I need to do something to fix it?

Thanks a lot.

I think the problem is related to the lib64 directory name. In normal situation, this directory is searched but can be controlled by FIND_LIBRARY_USE_LIB64_PATHS variable. Maybe your CMake environment set this variable with the wrong value…

Thanks for the reply,

It seems that even if I manually force FIND_LIBRARY_USE_LIB64_PATHS to true, it still does not work. However, using CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=64 makes it work well, so I will use this for the moment.

Thank you!

Strange. What is your compiler? lib64 will be searched only if your compiler generates 64bit binaries.

It’s GCC 11.4.1, but is seems that at the first call to find python, compiler version is still undefined. It looks like the call is not linked to any direct binary generation and is done only to collect information, so I guess that explain the behaviour.

Thank you!