-
Notifications
You must be signed in to change notification settings - Fork 65
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
Use find_package(Python) instead of PythonInterp #1007
base: master
Are you sure you want to change the base?
Use find_package(Python) instead of PythonInterp #1007
Conversation
.github/workflows/pip-build-osx.yml
Outdated
@@ -45,7 +45,7 @@ jobs: | |||
python --version | |||
mkdir build | |||
cd build | |||
cmake -DCMAKE_BUILD_TYPE=Release -DPython_ADDITIONAL_VERSIONS=3 .. | |||
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$(which python) .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I precised it on 7e33f42 because macosx-11.7-universal2 has several python installation available and cmake was not finding the correct one, cf. https://github.com/GUDHI/gudhi-devel/actions/runs/7030598162/job/19130456933#step:5:60
When I precise Python_EXECUTABLE
, the error is no more.
I wanted to do the same for Windows, but my batch command seems not correct, WIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my question is whether users are likely to be hindered by this change in our CMake scripts (just like we were affected in our CI), and how we could help. For instance, if cmake happily stops when it finds a version of python that doesn't have the development parts, we could tell find_package that we require components Interpreter and Development.Module (and possibly NumPy) so hopefully it keeps looking for another python in that case. There are also several options that can affect the strategy:
- setting policy CMP0094 to NEW changes Python_FIND_STRATEGY a bit
- Python_FIND_UNVERSIONED_NAMES can be set to FIRST if we prefer python to python3.X
There are also Python_FIND_REGISTRY (windows) and Python_FIND_FRAMEWORK (macos), but they don't look like things we should force on users. We could use them in CI, but in CI specifying the executable (as you did) is probably more reliable.
By the way, does Python_EXECUTABLE need a full path, or does -DPython_EXECUTABLE=python
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, does Python_EXECUTABLE need a full path, or does
-DPython_EXECUTABLE=python
work?
https://cmake.org/cmake/help/latest/module/FindPython.html says
Note: All paths must be absolute. Any artifact specified with a relative path will be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice it the first time I wrote the PR, but setting policy CMP0094 to NEW seems promising as it is using the python interpreter from my conda environment instead of the one from my system. It worth it to test it, even if it requires cmake 3.15 (july 2019). I rewrite some python cmake horrors and I will give it a try
…tation(). Use find_package to find numpy and its target (more modern cmake)
…he docker pip image that was in CMake 3.16.2
Modification taken from #151
Fix #139
CMake
3.12 is now 5 years old3.15 is now 4 years old (july 2019), so it should be ok for every one.CMake 3.15 is required for
cmake_policy(SET CMP0094 NEW)
CMake 3.16 (nov 2019) is required if the user wants to specify a python interpreter (
cmake -DPython_EXECUTABLE=/custom/path/to/python3 ...
)