Skip to content

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

@nickanthony-dgl

Description

@nickanthony-dgl

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

  • OS: Windows

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

Metadata

Metadata

Assignees

Labels

Stalecategory:port-featureThe issue is with a library, which is requesting new capabilities that didn’t exist

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions