Updates to CMake Python discovery code and issues with Python discovery
As part of some updates to the packaging code, @ccantwel highlighted a problem with correctly discovering Python 3 on Centos 7 which was preventing the CMake configuration process from completing.
Currently, the code for Python discovery simply uses:
FIND_PACKAGE(PythonInterp REQUIRED) FIND_PACKAGE(PythonLibsNew REQUIRED)
On Centos 7, this successfully finds the Python interpreter but not the libs, causing the CMake configuration to fail if Python is enabled (
According to the docs for the CMake Python discovery modules, (e.g. FindPythonInterp), FindPythonInterp and FindPythonLibs have been deprecated since CMake 3.12 in favour of FindPython or FindPython2 / FindPython3.
I've added some new code in this commit to use the revised approach to finding Python if CMake >= 3.12 is being used. However, while investigating this, I discovered that a few months ago, we used to have code in ThirdPartyPython.cmake (see ThirdPartyPython.cmake:@cc50164f) which did take the version of Python into account and search specifically for a particular version of the interpreter and libs. I'm not sure whether that, in itself, would have prevented the issues with Centos 7 but I suspect it might have.
I'm guessing these changes were made with a view to Python 2.7 being EOL and moving entirely to Python 3? At the same time, if we're still going to support older distros, maybe this is something to address?
I think I recall some discussion about this a while ago but perhaps we could replace
NEKTAR_USE_PYTHON2 and search for Python 3 by default but look for Python 2.7 if
On the other hand, maybe this results in unnecessary changes given that Python 2.7 officially reached EOL 1 year ago and any remaining use of it is only going to decrease?