microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.31k stars 6.44k forks source link

[pybind11] port breaks MLIR Python detection #42237

Open Time0o opened 3 days ago

Time0o commented 3 days ago

Describe the bug

I am trying to include the pybind11 vcpkg port in a CMake project that also depends on MLIR (which I don't include via vcpkg). Both work independently, but when used together, MLIR is unable to find Development.Module NumPy. MLIR already has already introduced the MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH variable to deal with the partially broken Python search capabilities of CMake, see here. But whether or not this is set, the problem remains for me (at least on MacOS). Python is found but the NumPy development module is not.

Environment

To Reproduce

A minimal example just involves adding pybind11 via vcpkg, setting CMAKE_TOOLCHAIN_FILE and Python3_EXECUTABLE appropriately and then adding the following in CMakeLists.txt (making MLIR_DIR point to an installation of MLIR):

find_package(MLIR REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
include(MLIRDetectPythonEnv)
mlir_configure_python_dev_packages()

Expected behavior

I would expect this to just work out of the box. When I integrate pybind11 into my project without vcpkg, i.e. by just pointing pybind11_DIR to an installation of pybind11 it works.

Failure logs

CMake Error at /opt/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find Python3 (missing: Development.Module NumPy) (found version
  "3.12.7")
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/FindPython/Support.cmake:4001 (find_package_handle_standard_args)
  /opt/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/FindPython3.cmake:602 (include)
  build-debug/vcpkg_installed/arm64-osx/share/python3/vcpkg-cmake-wrapper.cmake:72 (_find_package)
  /Users/timonicolai/github/vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
  /Users/timonicolai/github/llvm-project/build/lib/cmake/mlir/MLIRDetectPythonEnv.cmake:21 (find_package)
  CMakeLists.txt:39 (mlir_configure_python_dev_packages)
Osyotr commented 2 days ago

Which python did you expect to find?