Skip to content

[pybind11] fix issue where Python environment was restricted to versi…#52695

Draft
WentsingNee wants to merge 1 commit into
microsoft:masterfrom
WentsingNee:fix-pybind11
Draft

[pybind11] fix issue where Python environment was restricted to versi…#52695
WentsingNee wants to merge 1 commit into
microsoft:masterfrom
WentsingNee:fix-pybind11

Conversation

@WentsingNee

@WentsingNee WentsingNee commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version, or no changes were necessary.
  • Any fixed CI baseline and CI feature baseline entries are removed from that file, or no entries needed to be changed.
  • All patch files in the port are applied and succeed.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Exactly one version is added in each modified versions file.

@WentsingNee

WentsingNee commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi!

I found a problem that find_package(Python3) always found python3.12 installed by vcpkg under manifest mode. I've tried sepecify variables such as Python3_ROOT_DIR, Python3_FIND_STRATEGY , Python3_FIND_VIRTUALENV or Python3_EXECUTABLE however none of them can force cmake to find the python under conda envs. So I decided to let the dependency of python3 as optional.

@ricardoofnl ricardoofnl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direction makes sense: the port itself is built with -DPYBIND11_NOPYTHON=ON, so python3 was only ever a consumer convenience. Two things beyond the inline comments:

The arm64_linux CI failure is caused by scripts/ci.feature.baseline.txt line 1103 (pybind11:arm64-linux=cascade). With the hard python3 dependency removed, pybind11[core] and pybind11[core,python3] now pass on arm64-linux, so that baseline entry contradicts reality and has to be removed in this PR (checklist item 4).

Comment thread ports/pybind11/vcpkg.json
]
],
"features": {
"python3": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without "default-features": ["python3"] this silently changes behavior for every consumer. Of the 8 ports in the registry depending on pybind11, 4 do not declare python3 themselves (bbstrader, numcpp, tensorpipe, libtorch); they currently get vcpkg's Python transitively and would start resolving find_package(Python) to whatever system Python happens to exist. Either add the feature to default-features (users who want their own Python can install pybind11[core]), or update those 4 dependents to depend on python3 directly.

@BillyONeal BillyONeal Jul 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix those rather than trying to backcompat hack it up here. (If we do something like it at all)

Comment thread ports/pybind11/vcpkg.json
],
"features": {
"python3": {
"description": "python3 development environment",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: something like "Use vcpkg's python3 when consuming pybind11" would describe the effect better; the feature decides which Python find_package(Python) resolves to at configure time, it does not install a development environment for pybind11 itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion. I'm not a native English speaker and not good at writing. Forgive me plz :(

@Osyotr

Osyotr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

#49081 (comment)

@BillyONeal BillyONeal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Osyotr (and transitively @dg0yt ) note, this has been discussed before and forcing vcpkg's Python is intentional.

@BillyONeal BillyONeal marked this pull request as draft July 3, 2026 01:08
@WentsingNee

Copy link
Copy Markdown
Contributor Author

As @Osyotr (and transitively @dg0yt ) note, this has been discussed before and forcing vcpkg's Python is intentional.

I don't think that it's a good idea. vcpkg's Python is forzen at version 3.12 and has only development parts without interpreter. With forcing usage of vcpkg's Python, pybind extension of my project can only be built and used under Python3.12 and the users do not have any other methods to overwrite the options and can't decide the Python version they like.

@dg0yt

dg0yt commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Installation order problems are even worse than forcing python.
For specific builds, it is possible to use overlay ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants