microsoft / vcpkg

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

[python3] vcpkg-cmake-wrapper.cmake prevents finding system installed Python #42322

Open nickanthony-dgl opened 3 days ago

nickanthony-dgl commented 3 days ago

One of the packages listed in my manifest ("pybind11") has the "python3" package listed as a dependency which causes vcpkg to install Python 3.11. However, I have by own version of Python that I want to use like so: find_package(Python3 3.12 COMPONENTS Interpreter Development REQUIRED). When I didn't have vcpkg's Pyton 3.11 installed this worked fine, however I am now getting an error.

CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Python3: Found unsuitable version "3.11.10", but required is
  at least "3.12" (found
  C:/Users/NicholasAnthony/source/repos/wt_gui/external/WaveTracer/out/build/MSVC-Release/vcpkg_installed/x64-windows-digilens/tools/python3/python.exe,
  found components: Interpreter Development Development.Module
  Development.Embed)
Call Stack (most recent call first):
  C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:598 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPython/Support.cmake:3867 (find_package_handle_standard_args)
  C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPython3.cmake:545 (include)
  out/build/MSVC-Release/vcpkg_installed/x64-windows-digilens/share/python3/vcpkg-cmake-wrapper.cmake:72 (_find_package)
  C:/vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
  src/wt_imageAnalysisPy/CMakeLists.txt:2 (find_package)

It seems that this is because of this section in vcpkg-cmake-wrapper is overriding cmake's default behavior for finding python in order to force that VCPKG's version is found.

Environment

Expected behavior CMake's find_package(Python3 3.12 COMPONENTS Interpreter Development REQUIRED) works even when VCPKg has installed Python

jimwang118 commented 11 hours ago

You can use overlay-port to override vcpkg's python3 and use the python3 you installed.

dg0yt commented 11 hours ago

Full discussion in https://github.com/microsoft/vcpkg/issues/42323.