microsoft / microsoft/vcpkg

vcpkg toolchain overrides system Python interpreter and breaks external package paths

Open
#50,801 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CMake
Stars
27.5k
Forks
7.7k
Avg merge
2d 19h
Merged PRs (30d)
321

Description

**Describe the bug**
When using the vcpkg toolchain (vcpkg.cmake), vcpkg forces CMake to use its own bundled Python interpreter:
```log
-- Found Python: E:/vcpkg/installed/x64-windows/tools/python3/python.exe
```
This causes downstream failures when other packages (e.g., Halide installed via system Python) rely on the original Python environment. In my case, Halide was installed in the system Python (E:/Python/.pyenv/pyenv-win/versions/3.12.10/...), but vcpkg redirects CMake to look for HalideConfig.cmake under vcpkg’s Python path:
```log
include could not find requested file:
E:/vcpkg/installed/x64-windows/tools/python3/Lib/site-packages/halide/lib/cmake/Halide/HalideConfig.cmake
```

**Environment**
- OS: Windows
- Compiler: MSVC

**To Reproduce**
Steps to reproduce the behavior:
```cmake
find_package(Halide CONFIG REQUIRED)
```

**CMakePresets.json**:
```json
{
"version": 3,
"configurePresets": [
{
"name": "vcpkg",
"hidden": true,
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "base",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"generator": "Ninja",
"inherits": "vcpkg",
"cacheVariables": {
"CMAKE_SUPPRESS_DEVELOPER_WARNINGS": true,
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/${presetName}/bin",
"CMAKE_ARCHIVE_OUTPUT_DIRECTORY": "${sourceDir}/build/${presetName}/lib"
}
},
{
"name": "Debug-build",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Release-build",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "RelWithDebInfo-build",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "MinSizeRel-build",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel"
}
}
]
}
```

**Expected behavior**
The vcpkg toolchain should respect the user’s existing Python environment.

**Failure logs**
```log
[cmake] -- Found Python: E:/vcpkg/installed/x64-windows/tools/python3/python.exe (found suitable version "3.12.13", minimum required is "3") found components: Interpreter Development.Module
[cmake] CMake Error at E:/Python/.pyenv/pyenv-win/versions/3.12.10/share/cmake/Halide/HalideConfig.cmake:9 (include):
[cmake] include could not find requested file:
[cmake]
[cmake] E:/vcpkg/installed/x64-windows/tools/python3/Lib/site-packages/halide/lib/cmake/Halide/HalideConfig.cmake
[cmake] Call Stack (most recent call first):
[cmake] E:/vcpkg/scripts/buildsystems/vcpkg.cmake:908 (_find_package)
[cmake] examples/mnist/CMakeLists.txt:3 (find_package)
```

Contributor guide

Open the contributing guide

Research direction

Start with scripts/buildsystems/vcpkg.cmake around line 908 and inspect how the toolchain configures Python discovery. Reproduce the issue through examples/mnist/CMakeLists.txt and the supplied CMakePresets.json using find_package(Halide CONFIG REQUIRED). Done means the vcpkg toolchain no longer redirects this lookup away from the user’s existing Python environment while normal package discovery still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, python
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.