From 693a866b0361db2bef0e761217f44f2939a8c89e Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 10:39:02 -0600 Subject: [PATCH 01/19] Fix underline length to match text Not sure why this was not caught earlier (but it was just a warning, not an error). --- tribits/doc/build_ref/TribitsBuildReferenceBody.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst index 3ab4ce13f..f250aa83c 100644 --- a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst +++ b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst @@ -2952,7 +2952,7 @@ printed to cmake STDOUT. Show parent(s) commit info in the repo version output ----------------------------------------------------- +----------------------------------------------------- .. __SHOW_GIT_COMMIT_PARENTS: From 50c9c9910b8f9415b962c887cb5502fc347e71f3 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 09:24:49 -0600 Subject: [PATCH 02/19] Remove unneeded 'import imp' (#610) On RHEL8 with Python 3.12, got the error message: No module named 'imp' --- test/python_utils/gitdist_UnitTests.py | 1 - test/python_utils/lower_case_cmake_UnitTests.py | 1 - test/python_utils/mockprogram_UnitTests.py | 1 - 3 files changed, 3 deletions(-) diff --git a/test/python_utils/gitdist_UnitTests.py b/test/python_utils/gitdist_UnitTests.py index 684534264..8a56a6581 100644 --- a/test/python_utils/gitdist_UnitTests.py +++ b/test/python_utils/gitdist_UnitTests.py @@ -44,7 +44,6 @@ ################################# import sys -import imp import shutil from unittest_helpers import * diff --git a/test/python_utils/lower_case_cmake_UnitTests.py b/test/python_utils/lower_case_cmake_UnitTests.py index 67ce64b78..7cbf67ffa 100644 --- a/test/python_utils/lower_case_cmake_UnitTests.py +++ b/test/python_utils/lower_case_cmake_UnitTests.py @@ -7,7 +7,6 @@ import sys -import imp import shutil from unittest_helpers import * diff --git a/test/python_utils/mockprogram_UnitTests.py b/test/python_utils/mockprogram_UnitTests.py index e1a86f586..b3a58efcc 100644 --- a/test/python_utils/mockprogram_UnitTests.py +++ b/test/python_utils/mockprogram_UnitTests.py @@ -43,7 +43,6 @@ from unittest_helpers import * -import imp import shutil #thisFilePath = __file__ From 9ffce307e38a1dcc1f0690327d65cbcdf5523f81 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:39:46 -0600 Subject: [PATCH 03/19] Move string-replace.py and token-replace.py into tribits/refactoring/ (#610) These are reusable helper tools that we might as well snapshot with the rest of TriBITS. (These don't have automated tests but it is easy to verify they are working as they should.) --- refactoring/replace_include_directories_r.sh | 4 ++-- refactoring/replace_set_and_inc_dirs_r.sh | 4 ++-- {refactoring => tribits/refactoring}/string-replace.py | 0 {refactoring => tribits/refactoring}/token-replace.py | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename {refactoring => tribits/refactoring}/string-replace.py (100%) rename {refactoring => tribits/refactoring}/token-replace.py (100%) diff --git a/refactoring/replace_include_directories_r.sh b/refactoring/replace_include_directories_r.sh index 1e0fbb4f2..78219c906 100755 --- a/refactoring/replace_include_directories_r.sh +++ b/refactoring/replace_include_directories_r.sh @@ -17,10 +17,10 @@ echo echo "Replacing INCLUDE_DIRECTORIES with TRIBITS_INCLUDE_DIRECTORIES in all CMakeList.txt and *.cmake files ..." echo -find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/token-replace.py -t INCLUDE_DIRECTORIES -r TRIBITS_INCLUDE_DIRECTORIES -f {} \; +find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/../tribits/refactoring/token-replace.py -t INCLUDE_DIRECTORIES -r TRIBITS_INCLUDE_DIRECTORIES -f {} \; echo echo "Replacing include_directories with tribits_include_directories in all CMakeList.txt and *.cmake files ..." echo -find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/token-replace.py -t include_directories -r tribits_include_directories -f {} \; +find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/../tribits/refactoring/token-replace.py -t include_directories -r tribits_include_directories -f {} \; diff --git a/refactoring/replace_set_and_inc_dirs_r.sh b/refactoring/replace_set_and_inc_dirs_r.sh index 655107a15..12d261466 100755 --- a/refactoring/replace_set_and_inc_dirs_r.sh +++ b/refactoring/replace_set_and_inc_dirs_r.sh @@ -17,10 +17,10 @@ echo echo "Replacing SET_AND_INC_DIRS with TRIBITS_SET_AND_INC_DIRS in all CMakeList.txt and *.cmake files ..." echo -find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/token-replace.py -t SET_AND_INC_DIRS -r TRIBITS_SET_AND_INC_DIRS -f {} \; +find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/../tribits/refactoring/token-replace.py -t SET_AND_INC_DIRS -r TRIBITS_SET_AND_INC_DIRS -f {} \; echo echo "Replacing set_and_inc_dirs with tribits_set_and_inc_dirs in all CMakeList.txt and *.cmake files ..." echo -find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/token-replace.py -t set_and_inc_dirs -r tribits_set_and_inc_dirs -f {} \; +find . \( -name CMakeLists.txt -or -name "*.cmake" \) -exec ${_SCRIPT_DIR}/../tribits/refactoring/token-replace.py -t set_and_inc_dirs -r tribits_set_and_inc_dirs -f {} \; diff --git a/refactoring/string-replace.py b/tribits/refactoring/string-replace.py similarity index 100% rename from refactoring/string-replace.py rename to tribits/refactoring/string-replace.py diff --git a/refactoring/token-replace.py b/tribits/refactoring/token-replace.py similarity index 100% rename from refactoring/token-replace.py rename to tribits/refactoring/token-replace.py From 33432fd3d8d346c41ca1e4182a8b49fa3c5c48cc Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:55:01 -0600 Subject: [PATCH 04/19] Fix help msg on -o argument (#610) Noticed this while working on #610 --- tribits/refactoring/string-replace.py | 2 +- tribits/refactoring/token-replace.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tribits/refactoring/string-replace.py b/tribits/refactoring/string-replace.py index 2a04a691f..bb6b33a34 100755 --- a/tribits/refactoring/string-replace.py +++ b/tribits/refactoring/string-replace.py @@ -28,7 +28,7 @@ def getCmndLineOptions(): clp.add_argument( "-o", dest="outputFile", default="", - help="Input file (and also output if -o not specified)" ) + help="Output file (optional)" ) options = clp.parse_args(sys.argv[1:]) diff --git a/tribits/refactoring/token-replace.py b/tribits/refactoring/token-replace.py index 16e8b29e4..9c425a65a 100755 --- a/tribits/refactoring/token-replace.py +++ b/tribits/refactoring/token-replace.py @@ -31,7 +31,7 @@ def getCmndLineOptions(): clp.add_argument( "-o", dest="outputFile", default="", - help="Input file (and also output if -o not specified)" ) + help="Output file (optional)" ) options = clp.parse_args(sys.argv[1:]) From c0812ebb438bf7f6996d7f4dc1738d3af2105676 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 09:48:24 -0600 Subject: [PATCH 05/19] Replace assert_() with assertIn() (#610) With Python 3.12, the unittest.assert_() function no longer exists. --- test/python_utils/SnapshotDir_UnitTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/python_utils/SnapshotDir_UnitTests.py b/test/python_utils/SnapshotDir_UnitTests.py index e0a46b48c..4f995115c 100644 --- a/test/python_utils/SnapshotDir_UnitTests.py +++ b/test/python_utils/SnapshotDir_UnitTests.py @@ -99,7 +99,7 @@ def runSnapshotDirTestCase(testObject, cmndLineArgsList, cmndInterceptList, #print("ostr =", ostr) for passRegexExpr in passRegexExpressionsList: try: - testObject.assert_(re.search(passRegexExpr, ostr)) + testObject.assertTrue(re.search(passRegexExpr, ostr)) except Exception as e: print("\n\nCould not find regex='" + passRegexExpr + "' in generated " "output:\n") From 31bfe439037fa73c16dfa523acdae21b28f20a82 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 10:31:03 -0600 Subject: [PATCH 06/19] Assume standard Python3/pip3 install of docutils (#610) No sense generating a message about not being able to find 'rst2html' when modern systems don't even have that program. It is called 'rst2htm.py' (and 'rst2latex.py'). This was tested with Python 3.12. Signed-off-by: Roscoe A. Bartlett --- tribits/python_utils/GenerateDocUtilsOutput.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tribits/python_utils/GenerateDocUtilsOutput.py b/tribits/python_utils/GenerateDocUtilsOutput.py index 0eb02ef6e..cb2437d7a 100644 --- a/tribits/python_utils/GenerateDocUtilsOutput.py +++ b/tribits/python_utils/GenerateDocUtilsOutput.py @@ -39,13 +39,9 @@ def generateFile(filePath, generateCmnd, outFile=None, workingDir="", def addCmndLineOptions(clp): - # Find the right default for the current system - rst2html = "rst2html" - rst2latex = "rst2latex" - rst2htmlWhich = getCmndOutput("which rst2html", True, False) - if rst2htmlWhich == "" or re.match(".+no rst2html.+", rst2htmlWhich): - rst2html = rst2html+".py" - rst2latex = rst2latex+".py" + # Assume standard install of docutils with Python3 + rst2html = "rst2html.py" + rst2latex = "rst2latex.py" clp.add_option( "--file-base", dest="fileBase", type="string", From 552fa626e47cd1074768c5f0749bd3aa6407df67 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:03:00 -0600 Subject: [PATCH 07/19] Don't set PYTHON_EXECUTABLE to python3 (#610) We want to use default behavior to just pick up python3 by default --- dev_testing/generic/do-configure-mpi-debug | 1 - 1 file changed, 1 deletion(-) diff --git a/dev_testing/generic/do-configure-mpi-debug b/dev_testing/generic/do-configure-mpi-debug index 75294f1d5..afe95538f 100755 --- a/dev_testing/generic/do-configure-mpi-debug +++ b/dev_testing/generic/do-configure-mpi-debug @@ -27,7 +27,6 @@ fi cmake \ -D CMAKE_BUILD_TYPE:STRING="DEBUG" \ --D PYTHON_EXECUTABLE=$(which python3) \ -D TPL_ENABLE_MPI:BOOL=ON \ -D TriBITS_ENABLE_Fortran:BOOL=ON \ -D TriBITS_ENABLE_TESTS:BOOL=ON \ From 3e5471dcba0349735f5b16d93bc63e7b84ed444a Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:03:52 -0600 Subject: [PATCH 08/19] 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. --- test/core/CMakeLists.txt | 2 +- .../core/TestingFunctionMacro_UnitTests.cmake | 92 +++++++++++++++---- .../TribitsFindPythonInterp.cmake | 54 +++++++---- tribits/doc/guides/TribitsGuidesBody.rst | 32 +++---- 4 files changed, 127 insertions(+), 53 deletions(-) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 6460753c8..1b68b8dfd 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -49,7 +49,7 @@ tribits_add_advanced_test( TestingFunctionMacro_UnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 720" + "Final UnitTests Result: num_run = 724" "Final UnitTests Result: PASSED" ) diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index 05b8df98c..0f0aad3ac 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -157,6 +157,8 @@ function(unittest_tribits_create_reverse_list) endfunction() +########################################################################################## + function(unittest_tribits_find_python_interp) message("\n***") @@ -166,55 +168,107 @@ function(unittest_tribits_find_python_interp) set(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) set(TRIBITS_FIND_PYTHON_UNITTEST TRUE) + tribits_find_python_interp_uses_python_false() + tribits_find_python_interp_uses_python_empty() + tribits_find_python_interp_uses_python_true() + tribits_find_python_interp_requires_python_true() + tribits_find_python_interp_find_version_too_low() + tribits_find_python_interp_find_version_higher() + tribits_find_python_interp_python_executable_backward_compatible() + +endfunction() + + +function(tribits_find_python_interp_uses_python_false) message("tribits_find_python_interp(): ${PROJECT_NAME}_USES_PYTHON=FALSE") set(${PROJECT_NAME}_USES_PYTHON FALSE) global_set(MESSAGE_WRAPPER_INPUT) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT "-- ;NOTE: Skipping check for Python because; ${PROJECT_NAME}_USES_PYTHON='FALSE'") - unittest_compare_const(FIND_PythonInterp_ARGS + unittest_compare_const(FIND_Python3_ARGS "") +endfunction() - message("tribits_find_python_interp(): ${PROJECT_NAME}_USES_PYTHON=") - global_set(MESSAGE_WRAPPER_INPUT) - set(${PROJECT_NAME}_USES_PYTHON) - set(PYTHON_EXECUTABLE_UNITTEST_VAL /path/to/python2.4) + +function(tribits_find_python_interp_uses_python_empty) + message("tribits_find_python_interp(): ${PROJECT_NAME}_USES_PYTHON=''") + global_set(MESSAGE_WRAPPER_INPUT "") + set(${PROJECT_NAME}_USES_PYTHON "") + set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.8) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "-- ;PYTHON_EXECUTABLE='/path/to/python2.4'") + "-- ;Python3_EXECUTABLE='/path/to/python3.8'") +endfunction() + +function(tribits_find_python_interp_uses_python_true) message("tribits_find_python_interp(): ${PROJECT_NAME}_USES_PYTHON=TRUE") global_set(MESSAGE_WRAPPER_INPUT) set(${PROJECT_NAME}_USES_PYTHON TRUE) - global_set(PYTHON_EXECUTABLE_UNITTEST_VAL /path/to/python2.4) + global_set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.8) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "-- ;PYTHON_EXECUTABLE='/path/to/python2.4'") - unittest_compare_const(FIND_PythonInterp_ARGS - "PythonInterp") + "-- ;Python3_EXECUTABLE='/path/to/python3.8'") + unittest_compare_const(FIND_Python3_ARGS + "Python3;3.8") +endfunction() + +function(tribits_find_python_interp_requires_python_true) message("tribits_find_python_interp(): ${PROJECT_NAME}_REQUIRES_PYTHON=TRUE") global_set(MESSAGE_WRAPPER_INPUT) set(${PROJECT_NAME}_USES_PYTHON FALSE) set(${PROJECT_NAME}_REQUIRES_PYTHON TRUE) - set(PYTHON_EXECUTABLE_UNITTEST_VAL /path/to/python2.4) + set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.8) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "-- ;PYTHON_EXECUTABLE='/path/to/python2.4'") - unittest_compare_const(FIND_PythonInterp_ARGS - "PythonInterp;REQUIRED") + "-- ;Python3_EXECUTABLE='/path/to/python3.8'") + unittest_compare_const(FIND_Python3_ARGS + "Python3;3.8;REQUIRED") +endfunction() + - message("tribits_find_python_interp(): PythonInterp_FIND_VERSION=2.3") +function(tribits_find_python_interp_find_version_too_low) + message("tribits_find_python_interp(): ${PROJECT_NAME}_Python3_FIND_VERSION=3.7 (too low)") global_set(MESSAGE_WRAPPER_INPUT) - set(PythonInterp_FIND_VERSION 2.3) - set(PYTHON_EXECUTABLE_UNITTEST_VAL /dummy) + set(${PROJECT_NAME}_Python3_FIND_VERSION 3.7) + set(Python3_EXECUTABLE_UNITTEST_VAL /dummy) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "FATAL_ERROR;Error,; PythonInterp_FIND_VERSION=2.3 < 2.6; is not allowed!;-- ;PYTHON_EXECUTABLE='/dummy'") + "FATAL_ERROR;Error,; ${PROJECT_NAME}_Python3_FIND_VERSION=3.7 < 3.8; is not allowed!;-- ;Python3_EXECUTABLE='/dummy'") +endfunction() + + +function(tribits_find_python_interp_find_version_higher) + message("tribits_find_python_interp(): ${PROJECT_NAME}_Python3_FIND_VERSION=3.11") + global_set(MESSAGE_WRAPPER_INPUT) + set(${PROJECT_NAME}_REQUIRES_PYTHON TRUE) + set(${PROJECT_NAME}_Python3_FIND_VERSION 3.11) + set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.11) + tribits_find_python_interp() + unittest_compare_const(MESSAGE_WRAPPER_INPUT + "-- ;Python3_EXECUTABLE='/path/to/python3.11'") + unittest_compare_const(FIND_Python3_ARGS + "Python3;3.11;REQUIRED") +endfunction() + +function(tribits_find_python_interp_python_executable_backward_compatible) + message("tribits_find_python_interp(): PYTHON_EXECUTABLE backward compatibility") + global_set(MESSAGE_WRAPPER_INPUT) + set(PYTHON_EXECUTABLE /path/to/python3.10.2) + tribits_find_python_interp() + unittest_compare_const(MESSAGE_WRAPPER_INPUT + "DEPRECATION;Python3_EXECUTABLE being set by default to PYTHON_EXECUTABLE = '/path/to/python3.10.2' is deprecated!;\n\nNOTE: To Make these warnings go away, set -D; TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE=IGNORE (see the build reference guide).;-- ;Python3_EXECUTABLE='/path/to/python3.10.2'") + unittest_compare_const(FIND_Python3_ARGS + "Python3;3.8") endfunction() +########################################################################################## + + function(unittest_tribits_standardize_abs_paths) message("\n***") @@ -4844,4 +4898,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(720) +unittest_final_result(724) diff --git a/tribits/core/package_arch/TribitsFindPythonInterp.cmake b/tribits/core/package_arch/TribitsFindPythonInterp.cmake index 3e57bbbe0..5d89e61e7 100644 --- a/tribits/core/package_arch/TribitsFindPythonInterp.cmake +++ b/tribits/core/package_arch/TribitsFindPythonInterp.cmake @@ -7,35 +7,55 @@ # ***************************************************************************** # @HEADER + # 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}") + # Get minimum version of Python to find + set(${PROJECT_NAME}_Python3_FIND_VERSION_MIN "3.8") + if ("${${PROJECT_NAME}_Python3_FIND_VERSION_DEFAULT}" STREQUAL "") + set(${PROJECT_NAME}_Python3_FIND_VERSION_DEFAULT + "${${PROJECT_NAME}_Python3_FIND_VERSION_MIN}") endif() - advanced_set(PythonInterp_FIND_VERSION ${PythonInterp_FIND_VERSION_DEFAULT} + advanced_set(${PROJECT_NAME}_Python3_FIND_VERSION + ${${PROJECT_NAME}_Python3_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}") + "Default version of Python to find (must be ${${PROJECT_NAME}_Python3_FIND_VERSION_DEFAULT} or greater") + if (${PROJECT_NAME}_Python3_FIND_VERSION VERSION_LESS + "${${PROJECT_NAME}_Python3_FIND_VERSION_MIN}" + ) message_wrapper(FATAL_ERROR "Error," - " PythonInterp_FIND_VERSION=${PythonInterp_FIND_VERSION} < ${PythonInterp_FIND_VERSION_MIN}" + " ${PROJECT_NAME}_Python3_FIND_VERSION=${${PROJECT_NAME}_Python3_FIND_VERSION} < ${${PROJECT_NAME}_Python3_FIND_VERSION_MIN}" " is not allowed!" ) endif() - advanced_set(PythonInterp_MUST_BE_FOUND FALSE CACHE BOOL "Require Python to be found or not.") + # Provide backward compatibility for user setting PYTHON_EXECUTABLE + 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() + # Find Python 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(FIND_Python3_ARGS + Python3 ${${PROJECT_NAME}_Python3_FIND_VERSION} ${Python3_REQUIRED_ARG}) + if(DEFINED Python3_EXECUTABLE) + # Already defined (even if it is set to empty), so no need to call anything! + elseif (TRIBITS_FIND_PYTHON_UNITTEST) + set(Python3_EXECUTABLE ${Python3_EXECUTABLE_UNITTEST_VAL}) else() - find_package(${FIND_PythonInterp_ARGS}) + find_package(${FIND_Python3_ARGS}) endif() endmacro() +# Select the minimum version of Python + + + + # TriBITS Wrapper for finding Python (or not) for a TriBITS project. macro(tribits_find_python_interp) if (${PROJECT_NAME}_REQUIRES_PYTHON) @@ -48,9 +68,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() diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index c160ef68c..963755c88 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -1107,7 +1107,7 @@ can be used in the logic in these files. Some of the variables that should already be defined (in addition to all of the basic user TriBITS cache variables set in ``tribits_define_global_options_and_define_extra_repos()``) include ``CMAKE_HOST_SYSTEM_NAME``, ``${PROJECT_NAME}_HOSTNAME``, and -``PYTHON_EXECUTABLE`` (see `Python Support`_). The types of commands and +``Python3_EXECUTABLE`` (see `Python Support`_). The types of commands and logic to put in this file include: * Setting additional user cache variable options that are used by multiple @@ -2228,7 +2228,7 @@ proceeds through the call to `tribits_project()`_. | 3) Set variables ``CMAKE_HOST_SYSTEM_NAME`` and ``${PROJECT_NAME}_HOSTNAME`` | (both of these can be overridden in the cache by the user) | 4) Find some optional command-line tools: -| a) Find Python (sets ``PYTHON_EXECUTABLE``, see `Python Support`_) +| a) Find Python (sets ``Python3_EXECUTABLE``, see `Python Support`_) | b) Find Git (sets ``GIT_EXECUTABLE`` and ``GIT_VERSION_STRING``) | 5) ``include(`` `/Version.cmake`_ ``)`` | 6) Define primary TriBITS options and read in the list of extra repositories @@ -7003,17 +7003,16 @@ Python Support TriBITS Core does not require anything other than raw CMake. However, Python Utils, TriBITS CI Support, and other extended TriBITS components require -Python. These extra TriBITS tools only require Python 2.7+ (and 3.x). By -default, when a TriBITS project starts to configure using CMake, it will try -to find Python 2.7+ on the system (see `Full Processing of TriBITS Project -Files`_). If Python is found, it will set the global cache variable -``PYTHON_EXECUTABLE``. If it is not found, then it will print a warning and -``PYTHON_EXECUTABLE`` will be empty. With this default behavior, if Python is -found, then the TriBITS project can use it. Otherwise, it can do without it. +Python. These extra TriBITS tools only require Python 3.8+. By default, when +a TriBITS project starts to configure using CMake, it will try to find Python +3.8+ on the system (see `Full Processing of TriBITS Project Files`_). If +Python is found, it will set the global cache variable ``Python3_EXECUTABLE``. +If it is not found, then it will print a warning and ``Python3_EXECUTABLE`` +will be empty. With this default behavior, if Python is found, then the +TriBITS project can use it. Otherwise, it can do without it. While the default behavior for finding Python described above is useful for -many TriBITS project (such as Trilinos), some TriBITS projects need different -behavior such as: +many TriBITS projects, some TriBITS projects need different behavior such as: 1. The TriBITS project may not ever use Python so there is no need to look for it at all. In this case, the TriBITS project would set @@ -7023,11 +7022,12 @@ behavior such as: can't be found. In this case, the TriBITS project would set `${PROJECT_NAME}_REQUIRES_PYTHON`_ to ``TRUE``. -3. Some TriBITS projects may require a version of Python more recent than 2.7. - In this case, the TriBITS project would set `PythonInterp_FIND_VERSION`_ to - some value higher than ``2.7``. For example, may newer systems have only - Python 3.5.2 or higher versions installed by default and projects developed - on such a system typically requires this version or higher. +3. Some TriBITS projects may require a version of Python more recent than 3.8. + In this case, the TriBITS project would set + `${PROJECT_NAME}_Python3_FIND_VERSION`_ to some value higher than ``3.8``. + For example, may newer systems have higher versions of Python installed by + default, and projects developed on such a system typically require this + version or higher. Project-Specific Build Reference From 74f1e4ca15508c608291b3eb444b7a171607a9af Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:43:37 -0600 Subject: [PATCH 09/19] Add refactor script to replace PYTHON_EXECUTABLE with Python3_EXECUTABLE in CMake code (#610) --- tribits/refactoring/to-python3.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 tribits/refactoring/to-python3.sh diff --git a/tribits/refactoring/to-python3.sh b/tribits/refactoring/to-python3.sh new file mode 100755 index 000000000..2a295f5f6 --- /dev/null +++ b/tribits/refactoring/to-python3.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Usage: +# +# to-python3.sh +# + +_SCRIPT_DIR=`echo $0 | sed "s/\(.*\)\/to-python3[.]sh/\1/g"` +baseDir=$1 +find ${baseDir} -type f \ + \( -name CMakeLists.txt -or -name "*.cmake" -or -name "*.cmake.in" -or -name "*.rst" \) \ + -exec $_SCRIPT_DIR/token-replace.py -t PYTHON_EXECUTABLE -r Python3_EXECUTABLE -f {} ';' From 1ea5a2b74374f563786434a24e511a2c73d32d9f Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 3 Oct 2024 12:52:09 -0600 Subject: [PATCH 10/19] Run refactoring script to-python3.py on all CMake and related files (#610) This just renames PYTHON_EXECUTABLE to Python3_EXECUTABLE. --- test/CMakeLists.txt | 2 +- test/ci_support/CMakeLists.txt | 38 +++++++++---------- .../TribitsExampleProject_Tests.cmake | 2 +- .../MockCTestDriver/CMakeLists.txt | 4 +- test/devtools_install/CMakeLists.txt | 4 +- test/doc/CMakeLists.txt | 2 +- test/python_utils/CMakeLists.txt | 24 ++++++------ .../TribitsWriteXmlDependenciesFiles.cmake | 4 +- .../package_arch/TribitsGlobalMacros.cmake | 4 +- .../test_support/TribitsAddAdvancedTest.cmake | 2 +- .../ctest_driver/TribitsCTestDriverCore.cmake | 2 +- .../TribitsCTestDriverCoreHelpers.cmake | 8 ++-- .../cmake/CallbackSetupExtraOptions.cmake | 4 +- .../packages/wrap_external/CMakeLists.txt | 2 +- 14 files changed, 51 insertions(+), 51 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9f4797601..d414d7b29 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(core) -if (PYTHON_EXECUTABLE) +if (Python3_EXECUTABLE) add_subdirectories( python_utils ci_support diff --git a/test/ci_support/CMakeLists.txt b/test/ci_support/CMakeLists.txt index 1c0207b65..db1b1243f 100644 --- a/test/ci_support/CMakeLists.txt +++ b/test/ci_support/CMakeLists.txt @@ -93,7 +93,7 @@ tribits_add_advanced_test( XmlHtmlCDashOutputTest tribits_add_advanced_test( TribitsDependencies_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/TribitsDependencies_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -102,7 +102,7 @@ tribits_add_advanced_test( TribitsDependencies_UnitTests tribits_add_advanced_test( TribitsPackageFilePathUtils_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/TribitsPackageFilePathUtils_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -111,7 +111,7 @@ tribits_add_advanced_test( TribitsPackageFilePathUtils_UnitTests tribits_add_advanced_test( TribitsPackageTestNameUtils_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/TribitsPackageTestNameUtils_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -124,7 +124,7 @@ tribits_add_advanced_test( get_tribits_packages_default OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 TEST_0 - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages.py" --deps-xml-file="${CMAKE_CURRENT_SOURCE_DIR}/TrilinosPackageDependencies.gold.xml" @@ -136,7 +136,7 @@ tribits_add_advanced_test( get_tribits_packages_only_toplevel_packages OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 TEST_0 - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages.py" --deps-xml-file="${CMAKE_CURRENT_SOURCE_DIR}/TrilinosPackageDependencies.gold.xml" @@ -149,7 +149,7 @@ tribits_add_advanced_test( get_tribits_packages_all_packages OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 TEST_0 - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages.py" --deps-xml-file="${CMAKE_CURRENT_SOURCE_DIR}/TrilinosPackageDependencies.gold.xml" @@ -166,7 +166,7 @@ tribits_add_advanced_test( get_tribits_packages_from_last_tests_failed_1 OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 TEST_0 - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-last-tests-failed.py" --deps-xml-file="${CMAKE_CURRENT_SOURCE_DIR}/TrilinosPackageDependencies.gold.xml" @@ -182,7 +182,7 @@ tribits_add_advanced_test( get_tribits_packages_from_last_tests_failed_1 tribits_add_advanced_test( TribitsExampleProject_ProjectCiFileChangeLogic_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/TribitsExampleProject_ProjectCiFileChangeLogic_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -216,7 +216,7 @@ function(test_tribitsexampleproject_get_tribits_packages_from_files_list -P "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/TribitsDumpDepsXmlScript.cmake" TEST_2 - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-files-list.py" --deps-xml-file=TribitsExProjPackageDependencies.cmake @@ -281,7 +281,7 @@ function(test_tribitsexampleproject_w_tribits_get_tribits_packages_from_files_li -P "TribitsExampleProject/cmake/tribits/ci_support/TribitsDumpDepsXmlScript.cmake" TEST_4 - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS "TribitsExampleProject/cmake/tribits/ci_support/get-tribits-packages-from-files-list.py" --deps-xml-file=TribitsExProjPackageDependencies.cmake @@ -313,7 +313,7 @@ test_tribitsexampleproject_w_tribits_get_tribits_packages_from_files_list( tribits_add_advanced_test( clone_extra_repos_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/clone_extra_repos_UnitTests.py --with-cmake="${CMAKE_COMMAND}" -v @@ -323,7 +323,7 @@ tribits_add_advanced_test( clone_extra_repos_UnitTests tribits_add_advanced_test( CheckinTest_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/CheckinTest_UnitTests.py --with-cmake="${CMAKE_COMMAND}" -v @@ -339,7 +339,7 @@ tribits_add_advanced_test( CheckinTest_UnitTests tribits_add_advanced_test( cdash_build_testing_date_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/cdash_build_testing_date_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" @@ -383,7 +383,7 @@ tribits_add_advanced_test( TribitsStripCommentsFromCMakeCacheFile_large tribits_add_advanced_test( CDashQueryAnalyzeReport_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/CDashQueryAnalyzeReport_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -392,7 +392,7 @@ tribits_add_advanced_test( CDashQueryAnalyzeReport_UnitTests tribits_add_advanced_test( cdash_analyze_and_report_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/cdash_analyze_and_report_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -401,7 +401,7 @@ tribits_add_advanced_test( cdash_analyze_and_report_UnitTests tribits_add_advanced_test( CDashAnalyzeReportRandomFailures_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/CDashAnalyzeReportRandomFailures_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -410,7 +410,7 @@ tribits_add_advanced_test( CDashAnalyzeReportRandomFailures_UnitTests tribits_add_advanced_test( cdash_analyze_and_report_random_failures_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/cdash_analyze_and_report_random_failures_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -419,7 +419,7 @@ tribits_add_advanced_test( cdash_analyze_and_report_random_failures_UnitTests tribits_add_advanced_test( CreateIssueTrackerFromCDashQuery_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/CreateIssueTrackerFromCDashQuery_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -452,7 +452,7 @@ tribits_add_advanced_test( TribitsExampleProject_checkin_test TEST_2 MESSAGE "Run checkin-test.py script to make sure it finds base dir" - CMND ${PYTHON_EXECUTABLE} + CMND ${Python3_EXECUTABLE} ARGS -E TribitsExampleProject/cmake/tribits/ci_support/checkin-test.py --enable-all-packages=on --send-email-to= --send-email-to-on-push= --allow-no-pull PASS_REGULAR_EXPRESSION_ALL diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 7fc507096..3d68eefb7 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -1695,7 +1695,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage -DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=OFF ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "NOTE: Setting TribitsExProj_ENABLE_WrapExternal=OFF because PYTHON_EXECUTABLE=''" + "NOTE: Setting TribitsExProj_ENABLE_WrapExternal=OFF because Python3_EXECUTABLE=''" "Final set of enabled top-level packages: SimpleCxx MixedLang WithSubpackages 3" "Final set of enabled packages: SimpleCxx MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages 6" "Configuring done" diff --git a/test/ctest_driver/MockCTestDriver/CMakeLists.txt b/test/ctest_driver/MockCTestDriver/CMakeLists.txt index 720f112f2..e9883be15 100644 --- a/test/ctest_driver/MockCTestDriver/CMakeLists.txt +++ b/test/ctest_driver/MockCTestDriver/CMakeLists.txt @@ -645,7 +645,7 @@ create_ctest_dependency_handling_test_case( # -if (PYTHON_EXECUTABLE) +if (Python3_EXECUTABLE) create_ctest_dependency_handling_test_case( CI_EnableOnlyModified_ModifiedNone @@ -1061,7 +1061,7 @@ if (PYTHON_EXECUTABLE) # ToDo: Test modified package not to be implicitly enabled to not be enabled! -endif(PYTHON_EXECUTABLE) +endif(Python3_EXECUTABLE) # diff --git a/test/devtools_install/CMakeLists.txt b/test/devtools_install/CMakeLists.txt index b2e03048d..2d16ae61b 100644 --- a/test/devtools_install/CMakeLists.txt +++ b/test/devtools_install/CMakeLists.txt @@ -41,7 +41,7 @@ tribits_add_advanced_test( InstallProgramDriver_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/InstallProgramDriver_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -50,7 +50,7 @@ tribits_add_advanced_test( InstallProgramDriver_UnitTests tribits_add_advanced_test( install_devtools_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/install_devtools_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) diff --git a/test/doc/CMakeLists.txt b/test/doc/CMakeLists.txt index d5d83994e..6cc978641 100644 --- a/test/doc/CMakeLists.txt +++ b/test/doc/CMakeLists.txt @@ -14,7 +14,7 @@ tribits_add_advanced_test( sphinx_rst_generator_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 EXCLUDE_IF_NOT_TRUE HAS_PYTHON3 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/sphinx_rst_generator_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ALWAYS_FAIL_ON_NONZERO_RETURN diff --git a/test/python_utils/CMakeLists.txt b/test/python_utils/CMakeLists.txt index d3588c4cd..7569074e6 100644 --- a/test/python_utils/CMakeLists.txt +++ b/test/python_utils/CMakeLists.txt @@ -40,7 +40,7 @@ tribits_add_advanced_test( GeneralScriptSupport_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/GeneralScriptSupport_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -48,7 +48,7 @@ tribits_add_advanced_test( GeneralScriptSupport_UnitTests tribits_add_advanced_test( mockprogram_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/mockprogram_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" XHOST travis-ci-server-linux @@ -57,7 +57,7 @@ tribits_add_advanced_test( mockprogram_UnitTests tribits_add_advanced_test( lower_case_cmake_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/lower_case_cmake_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" XHOST travis-ci-server-linux @@ -66,7 +66,7 @@ tribits_add_advanced_test( lower_case_cmake_UnitTests tribits_add_advanced_test( gitdist_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/gitdist_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" XHOST travis-ci-server-linux @@ -75,7 +75,7 @@ tribits_add_advanced_test( gitdist_UnitTests tribits_add_advanced_test( SnapshotDir_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/SnapshotDir_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -83,7 +83,7 @@ tribits_add_advanced_test( SnapshotDir_UnitTests tribits_add_advanced_test( extract_rst_cmake_doc_UnitTests OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/extract_rst_cmake_doc_UnitTests.py -v PASS_REGULAR_EXPRESSION "OK" ) @@ -97,7 +97,7 @@ set(EXTRACT_RST_CMAKE_DOC_DATA_DIR tribits_add_advanced_test( extract_rst_cmake_doc_help OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${EXTRACT_RST_CMAKE_DOC} --help PASS_REGULAR_EXPRESSION_ALL @@ -108,7 +108,7 @@ tribits_add_advanced_test( extract_rst_cmake_doc_help tribits_add_advanced_test( extract_rst_cmake_doc_extract_1_block_1_file OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${EXTRACT_RST_CMAKE_DOC} --extract-from=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/simpleDocText1.cmake --do-trace @@ -127,7 +127,7 @@ tribits_add_advanced_test( extract_rst_cmake_doc_extract_1_block_1_file tribits_add_advanced_test( extract_rst_cmake_doc_extract_2_blocks_2_files OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${EXTRACT_RST_CMAKE_DOC} --extract-from=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/simpleDocText1.cmake,${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/simpleDocText2.cmake --do-trace @@ -139,7 +139,7 @@ tribits_add_advanced_test( extract_rst_cmake_doc_extract_2_blocks_2_files tribits_add_advanced_test( extract_rst_cmake_doc_extract_2_blocks_glob_dir OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${EXTRACT_RST_CMAKE_DOC} --extract-from=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/ --do-trace @@ -151,7 +151,7 @@ tribits_add_advanced_test( extract_rst_cmake_doc_extract_2_blocks_glob_dir tribits_add_advanced_test( extract_rst_cmake_doc_extract_and_replace_2_blocks OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${EXTRACT_RST_CMAKE_DOC} --extract-from=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/ --rst-file-pairs=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/simpleTemplate1.rst:simple.rst @@ -169,7 +169,7 @@ tribits_add_advanced_test( extract_rst_cmake_doc_extract_and_replace_2_blocks tribits_add_advanced_test( extract_rst_cmake_doc_extract_and_replace_2_blocks_notrace OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 - TEST_0 CMND ${PYTHON_EXECUTABLE} + TEST_0 CMND ${Python3_EXECUTABLE} ARGS ${EXTRACT_RST_CMAKE_DOC} --extract-from=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/ --rst-file-pairs=${EXTRACT_RST_CMAKE_DOC_DATA_DIR}/simpleTemplate1.rst:simple.rst diff --git a/tribits/ci_support/TribitsWriteXmlDependenciesFiles.cmake b/tribits/ci_support/TribitsWriteXmlDependenciesFiles.cmake index 75b0a0276..021a235e4 100644 --- a/tribits/ci_support/TribitsWriteXmlDependenciesFiles.cmake +++ b/tribits/ci_support/TribitsWriteXmlDependenciesFiles.cmake @@ -52,7 +52,7 @@ macro(tribits_write_xml_dependency_files) " ${${PROJECT_NAME}_DEPS_HTML_OUTPUT_FILE} ..." ) set(tribitsCiSupportDir "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CI_SUPPORT_DIR}") execute_process( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${Python3_EXECUTABLE} ${tribitsCiSupportDir}/dump-package-dep-table.py --input-xml-deps-file=${${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE} --output-html-deps-file=${${PROJECT_NAME}_DEPS_HTML_OUTPUT_FILE} ) @@ -70,7 +70,7 @@ macro(tribits_write_xml_dependency_files) "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CTEST_DRIVER_DIR}") if (EXISTS "${tribitsCtestDriverDir}") execute_process( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${Python3_EXECUTABLE} ${tribitsCtestDriverDir}/dump-cdash-deps-xml-file.py --input-xml-deps-file=${${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE} --output-cdash-deps-xml-file=${${PROJECT_NAME}_CDASH_DEPS_XML_OUTPUT_FILE}) diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 5ca67ede6..d060ebd69 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -806,7 +806,7 @@ macro(tribits_define_global_options_and_define_extra_repos) "Output XML file containing ${PROJECT_NAME} dependenices used by tools (if not empty)." ) if(${PROJECT_NAME}_DEPS_DEFAULT_OUTPUT_DIR AND - ${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE AND PYTHON_EXECUTABLE + ${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE AND Python3_EXECUTABLE ) set(${PROJECT_NAME}_CDASH_DEPS_XML_OUTPUT_FILE_DEFAULT "${${PROJECT_NAME}_DEPS_DEFAULT_OUTPUT_DIR}/${${PROJECT_NAME}_CDASH_SUBPROJECT_DEPS_XML_FILE_NAME}" ) @@ -819,7 +819,7 @@ macro(tribits_define_global_options_and_define_extra_repos) "Output XML file used by CDash in ${PROJECT_NAME}-independent format (if not empty)." ) if(${PROJECT_NAME}_DEPS_DEFAULT_OUTPUT_DIR AND - ${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE AND PYTHON_EXECUTABLE + ${PROJECT_NAME}_DEPS_XML_OUTPUT_FILE AND Python3_EXECUTABLE ) set(${PROJECT_NAME}_DEPS_HTML_OUTPUT_FILE_DEFAULT "${${PROJECT_NAME}_DEPS_DEFAULT_OUTPUT_DIR}/${${PROJECT_NAME}_PACKAGE_DEPS_TABLE_HTML_FILE_NAME}" ) diff --git a/tribits/core/test_support/TribitsAddAdvancedTest.cmake b/tribits/core/test_support/TribitsAddAdvancedTest.cmake index 3f853da63..704a0d11e 100644 --- a/tribits/core/test_support/TribitsAddAdvancedTest.cmake +++ b/tribits/core/test_support/TribitsAddAdvancedTest.cmake @@ -354,7 +354,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/../utils/PrintVar.cmake") # # Instead, you have to use:: # -# CMND ${PYTHON_EXECUTABLE} ARGS /my_python_test.py ... +# CMND ${Python3_EXECUTABLE} ARGS /my_python_test.py ... # # ``ARGS "" "" ... ""`` # diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index ccd1a2b8c..d33c29fbf 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -141,7 +141,7 @@ tribits_project_read_version_file(${TRIBITS_PROJECT_ROOT}) include(TribitsFindPythonInterp) tribits_find_python() -message("PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}") +message("Python3_EXECUTABLE = ${Python3_EXECUTABLE}") ############################# ### Do some initial setup ### diff --git a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake index 76cfa19c6..e0b7116cc 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake @@ -175,7 +175,7 @@ endfunction() # function(tribits_create_repo_updates_file) extrarepo_execute_process_wrapper( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${Python3_EXECUTABLE} ${GITDIST_EXE} --dist-no-color log "--pretty=format:%h: %s%nAuthor: %an <%ae>%nDate: %ad%n" --name-status -C ORIG_HEAD..HEAD @@ -376,14 +376,14 @@ macro(enable_only_modified_packages) # A.3) Get the names of the modified packages - if (NOT PYTHON_EXECUTABLE) + if (NOT Python3_EXECUTABLE) message(FATAL_ERROR "Error, Python must be enabled to map from modified" " files to packages!") endif() if (EXISTS "${MODIFIED_FILES_FILE_NAME}") execute_process( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${Python3_EXECUTABLE} ${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-files-list.py --files-list-file=${MODIFIED_FILES_FILE_NAME} --project-dir=${TRIBITS_PROJECT_ROOT} @@ -847,7 +847,7 @@ function(tribits_get_failed_packages_from_failed_tests LAST_TESTS_FAILED_FILE FAILED_PACKAGES_OUT ) execute_process( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${Python3_EXECUTABLE} "${${PROJECT_NAME}_TRIBITS_DIR}/ci_support/get-tribits-packages-from-last-tests-failed.py" "--deps-xml-file=${CTEST_BINARY_DIRECTORY}/${${PROJECT_NAME}_PACKAGE_DEPS_XML_FILE_NAME}" "--last-tests-failed-file=${LAST_TESTS_FAILED_FILE}" diff --git a/tribits/examples/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake b/tribits/examples/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake index 7a66eb1f9..fd9d8f539 100644 --- a/tribits/examples/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake +++ b/tribits/examples/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake @@ -12,11 +12,11 @@ macro(TRIBITS_REPOSITORY_SETUP_EXTRA_OPTIONS) set(${PROJECT_NAME}_ENABLE_WrapExternal OFF) endif() - if ("${PYTHON_EXECUTABLE}" STREQUAL "") + if ("${Python3_EXECUTABLE}" STREQUAL "") message( "\n***" "\n*** NOTE: Setting ${PROJECT_NAME}_ENABLE_WrapExternal=OFF" - " because PYTHON_EXECUTABLE=''!" + " because Python3_EXECUTABLE=''!" "\n***\n" ) set(${PROJECT_NAME}_ENABLE_WrapExternal OFF) diff --git a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt index a9f8b0a37..bd0f4ef75 100644 --- a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt @@ -82,7 +82,7 @@ add_custom_command( OUTPUT ${EXTERNAL_FUNC_MAKEFILE} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${EXTERNAL_FUNC_SOURCE_DIR}/configure.py - COMMAND ${PYTHON_EXECUTABLE} ${EXTERNAL_FUNC_SOURCE_DIR}/configure.py + COMMAND ${Python3_EXECUTABLE} ${EXTERNAL_FUNC_SOURCE_DIR}/configure.py "--cxx=${CMAKE_CXX_COMPILER}" "--cxx-flags=${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${upperBuildType}}" "--ar=${CMAKE_AR}" From a6d8de63ef8077dadf46338ff4db6a282e5429cf Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 10:36:25 -0600 Subject: [PATCH 11/19] Manually change PYTHON_EXECUTABLE to Python3_EXECUTABLE (#610) This was not a token match so it did not match. I had to fix manually. --- test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 3d68eefb7..67d7e611e 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -1688,7 +1688,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage ${TribitsExampleProject_COMMON_CONFIG_ARGS} -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -DTribitsExProj_ENABLE_Fortran=ON - -DPYTHON_EXECUTABLE= + -DPython3_EXECUTABLE= -DTribitsExProj_ENABLE_ALL_PACKAGES=ON -DTribitsExProj_ENABLE_TESTS=ON -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON From e0eb70280dcb457a5f23cec4a5422406f5376cb9 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 10:42:00 -0600 Subject: [PATCH 12/19] Add build ref section 'Setting or disabling Python' (#610) I can't believe there was never a section on setting or disabling Python from a TriBITS project user's perspective. We have tests in TriBITS for the various behavior and TriBITS project developers users guide doc for the handling of Python. Signed-off-by: Roscoe A. Bartlett --- .../doc/build_ref/TribitsBuildReferenceBody.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst index f250aa83c..c7351ebe2 100644 --- a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst +++ b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst @@ -2230,6 +2230,21 @@ This will override the global behavior set by ````. +Setting or disabling Python +---------------------------- + +To set which Python interpreter is used, configure with:: + + -D Python3_EXECUTABLE= + +Otherwise, Python will be found automatically by default using +``find_python(Python3)`` internally. + +To disable the finding and usage of Python, configure with:: + + -D Python3_EXECUTABLE= + + Outputting package dependency information ----------------------------------------- From fa84823b631dd375b57642892316fbe4b0040883 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 4 Oct 2024 14:07:51 -0600 Subject: [PATCH 13/19] Adjust clone tests for old Python implementation (#610) These tests clone older versions of TribitsExampleProject that are still using logic to disable the WrapExternal package based on PYTHON_EXECUTABLE. Therefore, with new TriBITS implementation setting Python3_EXECUTABLE, the old logic does not allow the enable of WrapExternal and therefore there is one less test (10 vs. 11). This commit adjusts the regex for the number of tests being run for that change. Once these external repo snapshots are updated, then we will need to revert this commit (and fix the SHA1s as usual). Signed-off-by: Roscoe A. Bartlett --- .../TribitsExampleMetaProject/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt index d2e02af84..d7a2fa48a 100644 --- a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt @@ -152,7 +152,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re "Configure PASSED!" "CTEST_NOTES_FILES='.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote/BUILD/TribitsExMetaProjRepoVersion.txt[;].*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote/BUILD/UpdateCommandsOutput.txt[;].*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote/BUILD/CMakeCache.clean.txt'" "Build PASSED!" - "100% tests passed, 0 tests failed out of 11" + "100% tests passed, 0 tests failed out of 10" "Addon1 .*=.*.* sec[*]proc [(]1 test[)]" "MixedLang .* =.*.* sec[*]proc [(]1 test[)]" "SimpleCxx .*=*.* sec[*]proc [(]2 tests[)]" @@ -232,7 +232,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re "Configure PASSED!" "CTEST_NOTES_FILES='.*/BUILD/TribitsExMetaProjRepoVersion.txt[;].*/BUILD/Updates.txt[;].*/BUILD/UpdateCommandsOutput.txt[;].*/tribits/examples/TribitsExampleMetaProject/README[;].*/BUILD/CMakeCache.clean.txt'" "Build PASSED!" - "100% tests passed, 0 tests failed out of 11" + "100% tests passed, 0 tests failed out of 10" "Addon1 .*=.*.* sec[*]proc [(]1 test[)]" "MixedLang .* =.*.* sec[*]proc [(]1 test[)]" "SimpleCxx .*=*.* sec[*]proc [(]2 tests[)]" @@ -315,7 +315,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re "Configure PASSED!" "CTEST_NOTES_FILES='.*/BUILD/TribitsExMetaProjRepoVersion.txt[;].*/BUILD/Updates.txt[;].*/BUILD/UpdateCommandsOutput.txt[;].*/BUILD/CMakeCache.clean.txt'" "Build PASSED!" - "100% tests passed, 0 tests failed out of 11" + "100% tests passed, 0 tests failed out of 10" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_12 @@ -404,7 +404,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re "ctest_update[(][.][.][.][)] returned '0'" "Configure PASSED!" "Build PASSED!" - "100% tests passed, 0 tests failed out of 11" + "100% tests passed, 0 tests failed out of 10" ALWAYS_FAIL_ON_NONZERO_RETURN ) @@ -454,7 +454,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_custom_branch_rem "Configure PASSED!" "CTEST_NOTES_FILES='.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_custom_branch_remote/BUILD/TribitsExMetaProjRepoVersion.txt[;].*/TriBITS_CTestDriver_TribitsExMetaProj_clone_custom_branch_remote/BUILD/UpdateCommandsOutput.txt[;].*/TriBITS_CTestDriver_TribitsExMetaProj_clone_custom_branch_remote/BUILD/CMakeCache.clean.txt'" "Build PASSED!" - "100% tests passed, 0 tests failed out of 11" + "100% tests passed, 0 tests failed out of 10" "Addon1 .*=.*.* sec[*]proc [(]1 test[)]" "MixedLang .* =.*.* sec[*]proc [(]1 test[)]" "SimpleCxx .*=*.* sec[*]proc [(]2 tests[)]" @@ -568,7 +568,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_custom_branch_rem "Configure PASSED!" "CTEST_NOTES_FILES='.*/BUILD/TribitsExMetaProjRepoVersion.txt[;].*/BUILD/Updates.txt[;].*/BUILD/UpdateCommandsOutput.txt[;].*/BUILD/CMakeCache.clean.txt'" "Build PASSED!" - "100% tests passed, 0 tests failed out of 11" + "100% tests passed, 0 tests failed out of 10" ALWAYS_FAIL_ON_NONZERO_RETURN # NOTE: The above use case requires the custom git commands used by # ctest_update(). The default git commits used inside of ctest_update() From 15d05c030a688a845ddc528570b03c901a295c4c Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Mon, 7 Oct 2024 21:29:20 -0400 Subject: [PATCH 14/19] Move tribits_find_python_interp() to top in clean code ordering (#610) --- .../TribitsFindPythonInterp.cmake | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/tribits/core/package_arch/TribitsFindPythonInterp.cmake b/tribits/core/package_arch/TribitsFindPythonInterp.cmake index 5d89e61e7..4e9cc2b33 100644 --- a/tribits/core/package_arch/TribitsFindPythonInterp.cmake +++ b/tribits/core/package_arch/TribitsFindPythonInterp.cmake @@ -8,6 +8,30 @@ # @HEADER +# TriBITS Wrapper for finding Python (or not) for a TriBITS project. +macro(tribits_find_python_interp) + if (${PROJECT_NAME}_REQUIRES_PYTHON) + set(${PROJECT_NAME}_USES_PYTHON TRUE) + endif() + if ("${${PROJECT_NAME}_USES_PYTHON}" STREQUAL "") + # Unless the project tells us they can use Python or not, let's go ahead + # and look for Python in case some packages want to use it. + set(${PROJECT_NAME}_USES_PYTHON TRUE) + endif() + if (${PROJECT_NAME}_USES_PYTHON) + tribits_find_python() + 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() + message_wrapper("-- " "NOTE: Skipping check for Python because" + " ${PROJECT_NAME}_USES_PYTHON='${${PROJECT_NAME}_USES_PYTHON}'") + endif() +endmacro() + + # Find Python executable which is needed for dependency file building macro(tribits_find_python) # Get minimum version of Python to find @@ -56,25 +80,3 @@ endmacro() -# TriBITS Wrapper for finding Python (or not) for a TriBITS project. -macro(tribits_find_python_interp) - if (${PROJECT_NAME}_REQUIRES_PYTHON) - set(${PROJECT_NAME}_USES_PYTHON TRUE) - endif() - if ("${${PROJECT_NAME}_USES_PYTHON}" STREQUAL "") - # Unless the project tells us they can use Python or not, let's go ahead - # and look for Python in case some packages want to use it. - set(${PROJECT_NAME}_USES_PYTHON TRUE) - endif() - if (${PROJECT_NAME}_USES_PYTHON) - tribits_find_python() - 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() - message_wrapper("-- " "NOTE: Skipping check for Python because" - " ${PROJECT_NAME}_USES_PYTHON='${${PROJECT_NAME}_USES_PYTHON}'") - endif() -endmacro() From 3958edc9e2fe153e05bc42714ce89873d68adfd6 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Mon, 7 Oct 2024 21:38:17 -0400 Subject: [PATCH 15/19] Factor tribits_find_python() into smaller macros (#610) Just clearning, more self-documenting code --- .../TribitsFindPythonInterp.cmake | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tribits/core/package_arch/TribitsFindPythonInterp.cmake b/tribits/core/package_arch/TribitsFindPythonInterp.cmake index 4e9cc2b33..4e40facf2 100644 --- a/tribits/core/package_arch/TribitsFindPythonInterp.cmake +++ b/tribits/core/package_arch/TribitsFindPythonInterp.cmake @@ -34,6 +34,13 @@ endmacro() # Find Python executable which is needed for dependency file building macro(tribits_find_python) + tribits_find_python_set_python3_find_version() + tribits_find_python_backward_compatible_python_executable() + tribits_find_python_find_python3() +endmacro() + + +macro(tribits_find_python_set_python3_find_version) # Get minimum version of Python to find set(${PROJECT_NAME}_Python3_FIND_VERSION_MIN "3.8") if ("${${PROJECT_NAME}_Python3_FIND_VERSION_DEFAULT}" STREQUAL "") @@ -51,13 +58,21 @@ macro(tribits_find_python) " ${PROJECT_NAME}_Python3_FIND_VERSION=${${PROJECT_NAME}_Python3_FIND_VERSION} < ${${PROJECT_NAME}_Python3_FIND_VERSION_MIN}" " is not allowed!" ) endif() +endmacro() + + +macro(tribits_find_python_backward_compatible_python_executable) # Provide backward compatibility for user setting PYTHON_EXECUTABLE 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() - # Find Python +endmacro() + + +macro(tribits_find_python_find_python3) + # Find Python3 if (${PROJECT_NAME}_REQUIRES_PYTHON) set(Python3_REQUIRED_ARG "REQUIRED") else() @@ -75,8 +90,4 @@ macro(tribits_find_python) endmacro() -# Select the minimum version of Python - - - From c59141333f242aa7e5ef657f45ce564b27057c3d Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Tue, 8 Oct 2024 19:34:15 -0400 Subject: [PATCH 16/19] Add changelog entry for moving to find_package(Python3) (#610) --- tribits/CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index b3f1edd1e..ca6a8724d 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -2,6 +2,28 @@ ChangeLog for TriBITS ---------------------------------------- +## 2024-10-08: + +* **Changed:** The internal TriBITS framework find operation for Python has + been changed from calling `find_package(PythonInterp)` (using the deprecated + `FindPythonInterp.cmake` module) to calling `find_package(Python3)`, which + will find `python3` in the path automatically. The internal variable set by + this operation was changed from `PYTHON_EXECUTABLE` to `Python3_EXECUTABLE` + and TriBITS projects need make that change as well when upgrading TriBITS. + (This change can be made automatically in all of the project's CMake files + by running the script `tribits/refactoring/to-python3.sh `.) However, + backward compatibility for users of TriBITS projects that set `-D + PYTHON_EXECUTABLE=` is provided. If a TriBITS project user sets `-D + PYTHON_EXECUTABLE=` in the cache, TriBITS will set that value `` + to `Python3_EXECUTABLE` and avoid the call to `find_package(Python3)`; + however, a deprecation warning we be issued by default. TriBITS project + users should change to use `-D Python3_EXECUTABLE=` instead, or just + remove setting `PYTHON_EXECUTABLE` or `Python3_EXECUTABLE` altogether and + just make sure that the desired `python3` executable is in the path. See + issue + [TriBITSPub/TriBITS#610](https://github.com/TriBITSPub/TriBITS/issues/610) + for more details. + ## 2023-06-22: * **Added:** Packages are now determined to be missing if their dependencies From 6fb7d5e6e078bf6b9d25e80e8c386c2000eb5723 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 9 Oct 2024 08:38:42 -0600 Subject: [PATCH 17/19] Reduce min Python version from 3.8 to 3.6 (#610) The default version of `python3` on RHEL8 machines in Python 3.6.8. (I am not sure where I got Python 3.8 from.) But note that RHEL8 machines also seem to have Python 3.11 and 3.12 installed as well. I am wondering if it would not be more wise to be pro-active and push the version of Python being required to a higher version that will be supported for longer. (Python 3.6 ended support at the end of 2021.) --- .../core/TestingFunctionMacro_UnitTests.cmake | 24 +++++++++---------- .../TribitsFindPythonInterp.cmake | 2 +- tribits/doc/guides/TribitsGuidesBody.rst | 8 +++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index 0f0aad3ac..baabce657 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -195,10 +195,10 @@ function(tribits_find_python_interp_uses_python_empty) message("tribits_find_python_interp(): ${PROJECT_NAME}_USES_PYTHON=''") global_set(MESSAGE_WRAPPER_INPUT "") set(${PROJECT_NAME}_USES_PYTHON "") - set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.8) + set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.6) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "-- ;Python3_EXECUTABLE='/path/to/python3.8'") + "-- ;Python3_EXECUTABLE='/path/to/python3.6'") endfunction() @@ -206,12 +206,12 @@ function(tribits_find_python_interp_uses_python_true) message("tribits_find_python_interp(): ${PROJECT_NAME}_USES_PYTHON=TRUE") global_set(MESSAGE_WRAPPER_INPUT) set(${PROJECT_NAME}_USES_PYTHON TRUE) - global_set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.8) + global_set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.6) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "-- ;Python3_EXECUTABLE='/path/to/python3.8'") + "-- ;Python3_EXECUTABLE='/path/to/python3.6'") unittest_compare_const(FIND_Python3_ARGS - "Python3;3.8") + "Python3;3.6") endfunction() @@ -220,23 +220,23 @@ function(tribits_find_python_interp_requires_python_true) global_set(MESSAGE_WRAPPER_INPUT) set(${PROJECT_NAME}_USES_PYTHON FALSE) set(${PROJECT_NAME}_REQUIRES_PYTHON TRUE) - set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.8) + set(Python3_EXECUTABLE_UNITTEST_VAL /path/to/python3.6) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "-- ;Python3_EXECUTABLE='/path/to/python3.8'") + "-- ;Python3_EXECUTABLE='/path/to/python3.6'") unittest_compare_const(FIND_Python3_ARGS - "Python3;3.8;REQUIRED") + "Python3;3.6;REQUIRED") endfunction() function(tribits_find_python_interp_find_version_too_low) - message("tribits_find_python_interp(): ${PROJECT_NAME}_Python3_FIND_VERSION=3.7 (too low)") + message("tribits_find_python_interp(): ${PROJECT_NAME}_Python3_FIND_VERSION=3.5 (too low)") global_set(MESSAGE_WRAPPER_INPUT) - set(${PROJECT_NAME}_Python3_FIND_VERSION 3.7) + set(${PROJECT_NAME}_Python3_FIND_VERSION 3.5) set(Python3_EXECUTABLE_UNITTEST_VAL /dummy) tribits_find_python_interp() unittest_compare_const(MESSAGE_WRAPPER_INPUT - "FATAL_ERROR;Error,; ${PROJECT_NAME}_Python3_FIND_VERSION=3.7 < 3.8; is not allowed!;-- ;Python3_EXECUTABLE='/dummy'") + "FATAL_ERROR;Error,; ${PROJECT_NAME}_Python3_FIND_VERSION=3.5 < 3.6; is not allowed!;-- ;Python3_EXECUTABLE='/dummy'") endfunction() @@ -262,7 +262,7 @@ function(tribits_find_python_interp_python_executable_backward_compatible) unittest_compare_const(MESSAGE_WRAPPER_INPUT "DEPRECATION;Python3_EXECUTABLE being set by default to PYTHON_EXECUTABLE = '/path/to/python3.10.2' is deprecated!;\n\nNOTE: To Make these warnings go away, set -D; TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE=IGNORE (see the build reference guide).;-- ;Python3_EXECUTABLE='/path/to/python3.10.2'") unittest_compare_const(FIND_Python3_ARGS - "Python3;3.8") + "Python3;3.6") endfunction() diff --git a/tribits/core/package_arch/TribitsFindPythonInterp.cmake b/tribits/core/package_arch/TribitsFindPythonInterp.cmake index 4e40facf2..209fbd47e 100644 --- a/tribits/core/package_arch/TribitsFindPythonInterp.cmake +++ b/tribits/core/package_arch/TribitsFindPythonInterp.cmake @@ -42,7 +42,7 @@ endmacro() macro(tribits_find_python_set_python3_find_version) # Get minimum version of Python to find - set(${PROJECT_NAME}_Python3_FIND_VERSION_MIN "3.8") + set(${PROJECT_NAME}_Python3_FIND_VERSION_MIN "3.6") if ("${${PROJECT_NAME}_Python3_FIND_VERSION_DEFAULT}" STREQUAL "") set(${PROJECT_NAME}_Python3_FIND_VERSION_DEFAULT "${${PROJECT_NAME}_Python3_FIND_VERSION_MIN}") diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index 963755c88..18507eddb 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -7003,9 +7003,9 @@ Python Support TriBITS Core does not require anything other than raw CMake. However, Python Utils, TriBITS CI Support, and other extended TriBITS components require -Python. These extra TriBITS tools only require Python 3.8+. By default, when +Python. These extra TriBITS tools only require Python 3.6+. By default, when a TriBITS project starts to configure using CMake, it will try to find Python -3.8+ on the system (see `Full Processing of TriBITS Project Files`_). If +3.6+ on the system (see `Full Processing of TriBITS Project Files`_). If Python is found, it will set the global cache variable ``Python3_EXECUTABLE``. If it is not found, then it will print a warning and ``Python3_EXECUTABLE`` will be empty. With this default behavior, if Python is found, then the @@ -7022,9 +7022,9 @@ many TriBITS projects, some TriBITS projects need different behavior such as: can't be found. In this case, the TriBITS project would set `${PROJECT_NAME}_REQUIRES_PYTHON`_ to ``TRUE``. -3. Some TriBITS projects may require a version of Python more recent than 3.8. +3. Some TriBITS projects may require a version of Python more recent than 3.6. In this case, the TriBITS project would set - `${PROJECT_NAME}_Python3_FIND_VERSION`_ to some value higher than ``3.8``. + `${PROJECT_NAME}_Python3_FIND_VERSION`_ to some value higher than ``3.6``. For example, may newer systems have higher versions of Python installed by default, and projects developed on such a system typically require this version or higher. From 3c1e8668b03dbe5fa08c8ed2df1d2416b59f6be4 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 9 Oct 2024 09:12:02 -0600 Subject: [PATCH 18/19] Increasing timeout for TriBITS tests from 100 to 200 seconds I am not sure what is going on with these machines, but the times for some of these TriBITS tests when run in parallel has fallen off a cliff. On my RHEL7 machine last year, most of those most expensive tests would complete in 30sec or less. --- dev_testing/cee-rhel8/do-configure.mpi-debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_testing/cee-rhel8/do-configure.mpi-debug b/dev_testing/cee-rhel8/do-configure.mpi-debug index f0fe28451..921e0cbc5 100755 --- a/dev_testing/cee-rhel8/do-configure.mpi-debug +++ b/dev_testing/cee-rhel8/do-configure.mpi-debug @@ -20,7 +20,7 @@ if [ -d "${tribits_install_test_dir}" ] ; then fi ${TRIBITS_BASE_DIR}/dev_testing/generic/do-configure-mpi-debug \ --DDART_TESTING_TIMEOUT=100 \ +-DDART_TESTING_TIMEOUT=200 \ -DCTEST_PARALLEL_LEVEL=16 \ -DTriBITS_CTEST_DRIVER_COVERAGE_TESTS=TRUE \ -DTriBITS_CTEST_DRIVER_MEMORY_TESTS=TRUE \ From 701bb484e5571cd368f04cc80ef74248f7e72959 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 9 Oct 2024 09:17:09 -0600 Subject: [PATCH 19/19] Revert "Assume standard Python3/pip3 install of docutils (#610)" This reverts commit 31bfe439037fa73c16dfa523acdae21b28f20a82. Turns out that on some RHEL8 machines, 'rst2thml' is installed, but not 'rst2html.py'. For example, for the hpws machines at SNL, /usr/bin/rst2html is installed with version: $ rst2html --version rst2html (Docutils 0.14, Python 3.6.8, on linux) So this logic looking for 'rst2thml' and 'rst2html.py' is still useful. --- tribits/python_utils/GenerateDocUtilsOutput.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tribits/python_utils/GenerateDocUtilsOutput.py b/tribits/python_utils/GenerateDocUtilsOutput.py index cb2437d7a..0eb02ef6e 100644 --- a/tribits/python_utils/GenerateDocUtilsOutput.py +++ b/tribits/python_utils/GenerateDocUtilsOutput.py @@ -39,9 +39,13 @@ def generateFile(filePath, generateCmnd, outFile=None, workingDir="", def addCmndLineOptions(clp): - # Assume standard install of docutils with Python3 - rst2html = "rst2html.py" - rst2latex = "rst2latex.py" + # Find the right default for the current system + rst2html = "rst2html" + rst2latex = "rst2latex" + rst2htmlWhich = getCmndOutput("which rst2html", True, False) + if rst2htmlWhich == "" or re.match(".+no rst2html.+", rst2htmlWhich): + rst2html = rst2html+".py" + rst2latex = rst2latex+".py" clp.add_option( "--file-base", dest="fileBase", type="string",