From 52f27398876a3177049977249e004770bd869e61 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 10 Jan 2024 15:24:05 -0800 Subject: [PATCH] Replace `PYTHON_EXECUTABLE` with `Python_EXECUTABLE`. Following the suggestion here: https://github.com/pybind/pybind11/pull/4786#issuecomment-1885448824 Piggy-backed: Minor pre-commit auto-fix for top_level_CMakeLists.txt PiperOrigin-RevId: 597371220 --- CMakeLists.txt | 3 +-- pybind11_abseil/tests/CMakeLists.txt | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01477b0..ceb65a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,6 @@ FetchContent_Declare( FetchContent_MakeAvailable(abseil-cpp pybind11) set(TOP_LEVEL_DIR ${CMAKE_CURRENT_LIST_DIR}) -include_directories(${TOP_LEVEL_DIR} - ${pybind11_INCLUDE_DIRS}) +include_directories(${TOP_LEVEL_DIR} ${pybind11_INCLUDE_DIRS}) add_subdirectory(pybind11_abseil) diff --git a/pybind11_abseil/tests/CMakeLists.txt b/pybind11_abseil/tests/CMakeLists.txt index c516a16..a423c30 100644 --- a/pybind11_abseil/tests/CMakeLists.txt +++ b/pybind11_abseil/tests/CMakeLists.txt @@ -8,15 +8,19 @@ target_link_libraries( shared_ptr_from_capsule absl::statusor) # cpp_capsule_tools_testing_test =============================================== -if(NOT DEFINED PYTHON_EXECUTABLE) - set(PYTHON_EXECUTABLE ${PYBIND11_PYTHON_EXECUTABLE_LAST}) +if(NOT DEFINED Python_EXECUTABLE) + if(NOT DEFINED PYBIND11_PYTHON_EXECUTABLE_LAST) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + else() + set(Python_EXECUTABLE ${PYBIND11_PYTHON_EXECUTABLE_LAST}) + endif() endif() add_test( NAME cpp_capsule_tools_testing_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$PYTHONPATH:${CMAKE_BINARY_DIR} - ${PYTHON_EXECUTABLE} + ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cpp_capsule_tools_testing_test.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) @@ -39,7 +43,7 @@ target_link_libraries( add_test( NAME absl_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$PYTHONPATH:${CMAKE_BINARY_DIR} - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absl_test.py + ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/absl_test.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # ok_status_singleton_test ===================================================== @@ -48,7 +52,7 @@ add_test( NAME ok_status_singleton_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$PYTHONPATH:${CMAKE_BINARY_DIR} - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ok_status_singleton_test.py + ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ok_status_singleton_test.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # missing_import =============================================================== @@ -66,7 +70,7 @@ add_test( NAME missing_import_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$PYTHONPATH:${CMAKE_BINARY_DIR} - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/missing_import_test.py + ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/missing_import_test.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # status_test ================================================================== @@ -74,7 +78,7 @@ add_test( add_test( NAME status_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$PYTHONPATH:${CMAKE_BINARY_DIR} - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/status_test.py + ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/status_test.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # status_example =============================================================== @@ -89,5 +93,5 @@ add_test( NAME status_example_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$PYTHONPATH:${CMAKE_BINARY_DIR} - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/status_example_test.py + ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/status_example_test.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})