From 7364e526684e90e3e86e3b31f39e5fc2bdea18d1 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:03:52 -0600 Subject: [PATCH] Change to find_package(Python3), set Python3_EXECUTABLE to PYTHON_EXECUTABLE (#610) Change from calling deprecated find_package(PythonInterp) to call find_package(Python3). To maintain backward compatibility for external users, set Python3_EXECUTABLE to PYTHON_EXECUTABLE if the former is unset and the later is set. The rest of TriBITS will need to be refactored to absorb this. --- .../TribitsFindPythonInterp.cmake | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/tribits/core/package_arch/TribitsFindPythonInterp.cmake b/tribits/core/package_arch/TribitsFindPythonInterp.cmake index 3e57bbbe0..430488163 100644 --- a/tribits/core/package_arch/TribitsFindPythonInterp.cmake +++ b/tribits/core/package_arch/TribitsFindPythonInterp.cmake @@ -9,29 +9,20 @@ # Find Python executable which is needed for dependency file building macro(tribits_find_python) - set(PythonInterp_FIND_VERSION_MIN "2.6") - if ("${PythonInterp_FIND_VERSION_DEFAULT}" STREQUAL "") - set(PythonInterp_FIND_VERSION_DEFAULT "${PythonInterp_FIND_VERSION_MIN}") + if ((NOT "${PYTHON_EXECUTABLE}" STREQUAL "") AND ("${Python3_EXECUTABLE}" STREQUAL "")) + tribits_deprecated("Python3_EXECUTABLE being set by default to PYTHON_EXECUTABLE = '${PYTHON_EXECUTABLE}' is deprecated!") + set(Python3_EXECUTABLE "${PYTHON_EXECUTABLE}" CACHE FILEPATH + "Set by default to PYTHON_EXECUTABLE!") endif() - advanced_set(PythonInterp_FIND_VERSION ${PythonInterp_FIND_VERSION_DEFAULT} - CACHE STRING - "Default version of Python to find (must be ${PythonInterp_FIND_VERSION_DEFAULT} or greater") - if (PythonInterp_FIND_VERSION VERSION_LESS "${PythonInterp_FIND_VERSION_MIN}") - message_wrapper(FATAL_ERROR "Error," - " PythonInterp_FIND_VERSION=${PythonInterp_FIND_VERSION} < ${PythonInterp_FIND_VERSION_MIN}" - " is not allowed!" ) - endif() - advanced_set(PythonInterp_MUST_BE_FOUND FALSE CACHE BOOL "Require Python to be found or not.") if (${PROJECT_NAME}_REQUIRES_PYTHON) - set(PythonInterp_REQUIRED_ARG "REQUIRED") + set(Python3_REQUIRED_ARG "REQUIRED") else() - set(PythonInterp_REQUIRED_ARG "") + set(Python3_REQUIRED_ARG "") endif() - set(FIND_PythonInterp_ARGS PythonInterp ${PythonInterp_REQUIRED_ARG}) if (TRIBITS_FIND_PYTHON_UNITTEST) - set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE_UNITTEST_VAL}) + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE_UNITTEST_VAL}) else() - find_package(${FIND_PythonInterp_ARGS}) + find_package(Python3 ${Python3_REQUIRED_ARG}) endif() endmacro() @@ -48,9 +39,9 @@ macro(tribits_find_python_interp) endif() if (${PROJECT_NAME}_USES_PYTHON) tribits_find_python() - print_var(PYTHON_EXECUTABLE) - if (${PROJECT_NAME}_REQUIRES_PYTHON AND PYTHON_EXECUTABLE STREQUAL "") - message_wrapper(FATAL_ERROR "Error, PYTHON_EXECUTABLE='' but" + print_var(Python3_EXECUTABLE) + if (${PROJECT_NAME}_REQUIRES_PYTHON AND Python3_EXECUTABLE STREQUAL "") + message_wrapper(FATAL_ERROR "Error, Python3_EXECUTABLE='' but" " ${PROJECT_NAME}_REQUIRES_PYTHON=${${PROJECT_NAME}_REQUIRES_PYTHON}!" ) endif() else()