pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.18k stars 2.06k forks source link

Update deprecated FindPython #4782

Closed infinitesnow closed 11 months ago

infinitesnow commented 11 months ago

CMake 2.27 removes support for deprecated FindPython scripts.

In case CMake is custom built/installed in /usr/local, it seems to pick up the version of FindPython from the /usr/share folder. This causes issues when, for example, using a custom built installation of Python in /usr/local: if the version is more recent than what's listed in the system CMake script, it's not picked up.

Use the new version of the script, so Python is picked up correctly.

Description

Suggested changelog entry:

infinitesnow commented 11 months ago

CMake 3.5 on Ubuntu 20 seems to be missing FindPython.

All other failures are missing pytest, which I believe to be unrelated to my patch.

henryiii commented 11 months ago

FindPython was added in 3.15, and we still have to support 3.10 or so. There are several options already implemented:

Anything else would not be backward compatible and would break a lot of code.

For the bug you are seeing, there might need to be a fix, but we can't break thousands of existing packages doing it. :)

henryiii commented 11 months ago

If you find a way to fix (or reproduce via docker) the /usr/local vs. /usr bug, we can discuss that. But we can't break existing packages that are not opting into 3.15+ only FindPython mode (technically, 3.18+ if you need Development.Module, which you have to do to build manylinux wheels or for PyPy support).

infinitesnow commented 10 months ago

I see. I encountered this bug while working at my previous company, but I don't have access to that repository anymore so unfortunately I'm unable to reproduce. Thanks for the review!