TriBITS
TriBITS copied to clipboard
Switch from find_package(PythonInterp) to find_package(Python3)
CC: @sebrowne, @ccober6, @rppawlo
Parent Epic:
- #411
Description
The TriBITS module TribitsFindPythonInterp.cmake (created by Bill Spotz back in the day) currently calls find_package(PythonInterp) which uses the module FindPythonInterp.cmake. According to:
- https://cmake.org/cmake/help/v3.23/module/FindPythonInterp.html
the FindPythonInterp.cmake module has been deprecated since CMake 3.12! This should be updated to use FindPython.cmake or FindPython3.cmake.
In fact, it seems that the old FindPythonInterp.cmake module can't find versions of Python 3.0 and greater (i.e. with the name python3). This causes problems (e.g. see #607).
The new FindPython3.cmake module returns a variable called Python3_EXECUTABLE while the old FindPythonInterp.cmake module returned a variable called PYTHON_EXECUTABLE. Therefore, you can't just swap calling find_package(PythonInterp ...) with find_package(Python3 ...). Doing so would break all of the existing configure scripts for TriBITS projects that are currently setting -DPYTHON_EXECUTABLE=$(which python3) and it would break all of the internal TriBITS code that keys off of PYTHON_EXECUTABLE. So this would be a major break in backward compatibility (but the changes would be easy to absorb on both ends).
NOTE: We could make it easier for users of TriBITS projects by putting in a check for a cache var PYTHON_EXECUTABLE and error out telling users that they must instead set Python3_EXECUTABLE. Then, we could make it easier for TriBITS projects using PYTHON_EXECUTABLE in internal CMake code by setting it to an error value like PYTHON_EXECUTABLE is no longer supported! Please use Python3_EXECTUABLE instead!. And we would put in a variable_watch(PYTHON_EXECUTABLE) to and execute and error if the project tried to set PYTHON_EXECUTABLE.
Workarounds
The current workaround is to just have users manually set:
-DPYTHON_EXECUTABLE=$(which python3)
But that is not great.