Python ABI flags break CMake builds (Was: graphics/opencv build failure: Could NOT find PythonLibs)

dl8dtl

Developer
With a recent cmake (3.31.2), I run into the following:

Code:
CMake Warning (dev) at cmake/OpenCVUtils.cmake:144 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  cmake/OpenCVDetectPython.cmake:64 (find_host_package)
  cmake/OpenCVDetectPython.cmake:286 (find_python)
  CMakeLists.txt:660 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PythonInterp: /usr/local/bin/python3.11 (found suitable version "3.11.11", minimum required is "3.2")
CMake Warning (dev) at cmake/OpenCVDetectPython.cmake:140 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  cmake/OpenCVDetectPython.cmake:286 (find_python)
  CMakeLists.txt:660 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is exact version "3.11.11")

I wonder how this port could ever be built with current cmake?
 
To be able to proceed with my portmaster -a, I just disabled Python support in opencv.
Still puzzling how it is supposed to work.
 
Found the reason:
This CMake FindPythonLibs package fails to find them if there are any Python ABI flags present.


(IMHO it's quite a misfeature to append them to library names.)

I had "--with-pydebug" checked as a port option in python3.11, this caused the respective libraries to be placed under config-3.11d/libpython-3.11d.a
instead of just config-3.11/libpython-3.11.a. Subsequently, the CMake module failed to find them there. This could be considered a bug in that CMake module, however, the module is deprecated already anyway. Nevertheless, KiCad, instead of changing their build system to the new CMake ideas, just ships the old deprecated module in their own hierarchy.

I decided to reinstall Python without the debugging option, then the libraries are found – but consequently, everything that has already been built depending on the libpython3.11d .so would break.
 
Back
Top