Revert "build: use `find_package(Python3)` if available"
This reverts commit cd84bfb8142bc7ff3a07a188ffb809f1d86d1fd7. Although
this passed the CI in phabricator, some of the bots are missing python3
packages, revert it temporarily.
GitOrigin-RevId: be884b79352de8917ad17fdb9bd70ec982ca8bdd
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7dadc5f..88e556f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -130,38 +130,16 @@
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
if(LLVM_INCLUDE_TESTS)
- if(CMAKE_VERSION VERSION_LESS 3.12)
- include(FindPythonInterp)
- if(NOT PYTHONINTERP_FOUND)
- message(FATAL_ERROR
- "Unable to find Python interpreter, required for builds and testing.
+ include(FindPythonInterp)
+ if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR
+"Unable to find Python interpreter, required for builds and testing.
- Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
- endif()
+Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
+ endif()
- if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 )
- message(FATAL_ERROR "Python 2.7 or newer is required")
- endif()
-
- add_executable(Python3::Interpreter IMPORTED)
- set_target_properties(Python3::Interpreter PROPERTIES
- IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
- set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
- else()
- find_package(Python3 COMPONENTS Interpreter)
- if(NOT Python3_Interpreter_FOUND)
- message(WARNING "Python3 not found, using python2 as a fallback")
- find_package(Python2 COMPONENTS Interpreter REQUIRED)
- if(Python2_VERSION VERSION_LESS 2.7)
- message(SEND_ERROR "Python 2.7 or newer is required")
- endif()
-
- # Treat python2 as python3
- add_executable(Python3::Interpreter IMPORTED)
- set_target_properties(Python3::Interpreter PROPERTIES
- IMPORTED_LOCATION ${Python2_EXECUTABLE})
- set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
- endif()
+ if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 )
+ message(FATAL_ERROR "Python 2.7 or newer is required")
endif()
# Check prebuilt llvm/utils.
diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt
index 3f58c4b..626256a 100644
--- a/bindings/python/tests/CMakeLists.txt
+++ b/bindings/python/tests/CMakeLists.txt
@@ -3,7 +3,7 @@
add_custom_target(check-clang-python
COMMAND ${CMAKE_COMMAND} -E env
CLANG_LIBRARY_PATH=$<TARGET_FILE_DIR:libclang>
- "${Python3_EXECUTABLE}" -m unittest discover
+ ${PYTHON_EXECUTABLE} -m unittest discover
DEPENDS libclang
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in
index 4527cca..daec694 100644
--- a/test/lit.site.cfg.py.in
+++ b/test/lit.site.cfg.py.in
@@ -27,7 +27,7 @@
config.enable_experimental_new_pass_manager = @ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER@
config.enable_threads = @LLVM_ENABLE_THREADS@
config.host_arch = "@HOST_ARCH@"
-config.python_executable = "@Python3_EXECUTABLE@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
config.has_plugins = @LLVM_ENABLE_PLUGINS@
diff --git a/utils/perf-training/CMakeLists.txt b/utils/perf-training/CMakeLists.txt
index 172076f..1f86122 100644
--- a/utils/perf-training/CMakeLists.txt
+++ b/utils/perf-training/CMakeLists.txt
@@ -23,7 +23,7 @@
)
add_custom_target(clear-profraw
- COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} profraw
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} profraw
COMMENT "Clearing old profraw data")
if(NOT LLVM_PROFDATA)
@@ -34,7 +34,7 @@
message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to llvm-profdata")
else()
add_custom_target(generate-profdata
- COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Merging profdata"
DEPENDS generate-profraw)
endif()
@@ -55,7 +55,7 @@
)
add_custom_target(clear-dtrace-logs
- COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
COMMENT "Clearing old dtrace data")
if(NOT CLANG_ORDER_FILE)
@@ -63,7 +63,7 @@
endif()
add_custom_target(generate-order-file
- COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $<TARGET_FILE:clang> --output ${CLANG_ORDER_FILE} ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $<TARGET_FILE:clang> --output ${CLANG_ORDER_FILE} ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating order file"
DEPENDS generate-dtrace-logs)
endif()
diff --git a/utils/perf-training/lit.site.cfg.in b/utils/perf-training/lit.site.cfg.in
index a1c6d6b..340a0e9 100644
--- a/utils/perf-training/lit.site.cfg.in
+++ b/utils/perf-training/lit.site.cfg.in
@@ -7,7 +7,7 @@
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
config.target_triple = "@TARGET_TRIPLE@"
-config.python_exe = "@Python3_EXECUTABLE@"
+config.python_exe = "@PYTHON_EXECUTABLE@"
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
diff --git a/utils/perf-training/order-files.lit.site.cfg.in b/utils/perf-training/order-files.lit.site.cfg.in
index 91f2b79..87406db 100644
--- a/utils/perf-training/order-files.lit.site.cfg.in
+++ b/utils/perf-training/order-files.lit.site.cfg.in
@@ -7,7 +7,7 @@
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
config.target_triple = "@TARGET_TRIPLE@"
-config.python_exe = "@Python3_EXECUTABLE@"
+config.python_exe = "@PYTHON_EXECUTABLE@"
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.