From b345d979543d3f42add7e563e9881448b15d01bf Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 7 Jun 2021 08:52:34 -0400 Subject: [PATCH] Patch out FindPythonInterp to hopefully fix Ubuntu build This is a bit of a hacky solution but in theory should work ok. There was discussion of bringing in FindPython3 from upstream CMake, which we could also do if someone is motivated... Fixes https://gitlab.com/kicad/code/kicad/-/issues/8553 --- CMakeModules/FindPythonInterp.cmake | 49 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/CMakeModules/FindPythonInterp.cmake b/CMakeModules/FindPythonInterp.cmake index 2664ef0bf5..885dc8356c 100644 --- a/CMakeModules/FindPythonInterp.cmake +++ b/CMakeModules/FindPythonInterp.cmake @@ -39,30 +39,33 @@ set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) set(_PYTHON3_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) -if(PythonInterp_FIND_VERSION) - if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") - string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}") - string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") - list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ}) - unset(_PYTHON_FIND_OTHER_VERSIONS) - if(NOT PythonInterp_FIND_VERSION_EXACT) - foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) - if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) - list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) - endif() - endforeach() - endif() - unset(_PYTHON_FIND_MAJ_MIN) - unset(_PYTHON_FIND_MAJ) - else() - list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION}) - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS}) - endif() -else() - set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) -endif() +# Disabling the "search every possible place" code for now +# see https://gitlab.com/kicad/code/kicad/-/issues/8553 -list(APPEND _Python_NAMES python) +#if(PythonInterp_FIND_VERSION) +# if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") +# string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}") +# string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") +# list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ}) +# unset(_PYTHON_FIND_OTHER_VERSIONS) +# if(NOT PythonInterp_FIND_VERSION_EXACT) +# foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) +# if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) +# list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) +# endif() +# endforeach() +# endif() +# unset(_PYTHON_FIND_MAJ_MIN) +# unset(_PYTHON_FIND_MAJ) +# else() +# list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION}) +# set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS}) +# endif() +#else() +# set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +#endif() + +list(APPEND _Python_NAMES python3 python) # Search for the preferred executable first if( ${PYTHON_ROOT_DIR} )