Skip to content

feat(cmake): FindPython by default #5553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

henryiii
Copy link
Collaborator

@henryiii henryiii commented Mar 6, 2025

Description

This makes FindPython the default, and introduces a COMPAT mode that sets common variables to reduce breakage. FindPythonInterp/Libs was removed in CMake 3.27, and has a lot of downsides like not supporting cross compilation (like for Pyodide) properly.

Suggested changelog entry:

* Enable FindPython mode by default, with a ``COMPAT`` mode that sets some of the old variables to ease transition.

Signed-off-by: Henry Schreiner <[email protected]>
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

LGTM — based only on very superficial understanding

@henryiii henryiii marked this pull request as ready for review March 11, 2025 22:10
@henryiii henryiii merged commit d28904f into pybind:master Mar 11, 2025
80 checks passed
@henryiii henryiii deleted the henryiii/feat/findpythoncompat branch March 11, 2025 22:10
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Mar 11, 2025
@PhilipDeegan
Copy link
Contributor

I may be mistaken, but it seems as a result of this, if we find python ourselves before finding pybind

the target pybind11::embed no longer forwards libpython leading to link errors

@henryiii
Copy link
Collaborator Author

This is the only change recently to CMake that I know of, so it probably is the culprit, but I don't see how yet, it shouldn't have changed anything if you find Python yourself first.

@henryiii
Copy link
Collaborator Author

AH, no, I think I see the problem. if(THING) is false in CMake unless THING is a variable. That means my logic is wrong in this case. Can fix.

@henryiii henryiii changed the title feat: FindPython by default feat(cmake): FindPython by default Mar 31, 2025
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Apr 1, 2025
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.

3 participants