Skip to content

Commit

Permalink
ENH: Run script for Python3 find_package upgrade
Browse files Browse the repository at this point in the history
Now that cmake FindPython3 can be universally
used, prefer to only use that set of variable
names for identifying the python executables.

Intial procesing with manual cleanup by:

ITK/Utilities/Maintenance/FindPython3_ModernizeCMake.sh
  • Loading branch information
hjmjohnson authored and dzenanz committed Aug 21, 2022
1 parent bfa85dd commit 55c7b7f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMake/ITKConfig.cmake.in
Expand Up @@ -141,4 +141,4 @@ set(ITK_WRAP_complex_double @ITK_WRAP_complex_double@)
set(ITK_WRAP_IMAGE_DIMS "@ITK_WRAP_IMAGE_DIMS@")
set(ITK_WRAP_VECTOR_COMPONENTS "@ITK_WRAP_VECTOR_COMPONENTS@")

set(ITK_WRAP_PYTHON_VERSION "@PYTHON_VERSION_STRING@")
set(ITK_WRAP_PYTHON_VERSION "@Python3_VERSION@")
2 changes: 1 addition & 1 deletion Modules/Bridge/NumPy/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16.3)
project(ITKBridgeNumPy)

set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")

if(NOT ITK_SOURCE_DIR)
find_package(ITK REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt
Expand Up @@ -455,10 +455,10 @@ endif()

#-----------------------------------------------------------------------------
# Python install
#find_package(PythonInterp REQUIRED)
#find_package(Python3 COMPONENTS Interpreter REQUIRED)
#macro(GET_PYTHON_SITE_PACKAGE dir)
# execute_process(
# COMMAND ${PYTHON_EXECUTABLE} "-c" "from distutils import sysconfig; print sysconfig.get_python_lib()"
# COMMAND ${Python3_EXECUTABLE} "-c" "from distutils import sysconfig; print sysconfig.get_python_lib()"
# #WORKING_DIRECTORY @LIBRARY_OUTPUT_PATH@
# RESULT_VARIABLE import_res
# OUTPUT_VARIABLE import_output
Expand Down
Expand Up @@ -246,12 +246,6 @@ function(cxx_executable name dir libs)
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
endfunction()

# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
# ITK The PythonInterp package finding contaminates the cmake cache and
# ITK may find a different version than is use by wrapping or documentation
# ITK generation. DO NOT USE find_package(PythonInterp)
# ITK find_package(PythonInterp)

# cxx_test_with_flags(name cxx_flags libs srcs...)
#
# creates a named C++ test that depends on the given libs and is built
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Doxygen/CMakeLists.txt
Expand Up @@ -97,7 +97,7 @@ if (ITK_BUILD_DOCUMENTATION)
file(COPY workbox-cli-config.js serviceWorker.js.in
DESTINATION ${ITK_BINARY_DIR}/Utilities/Doxygen/)

execute_process(COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/datetime.py"
execute_process(COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/datetime.py"
RESULT_VARIABLE CMD_RESULT
OUTPUT_VARIABLE _DATETIME)

Expand Down
2 changes: 1 addition & 1 deletion Wrapping/macro_files/itk_end_wrap_module.cmake
Expand Up @@ -392,7 +392,7 @@ ${DO_NOT_WAIT_FOR_THREADS_CALLS}

# Link the modules together
target_link_libraries(${lib} LINK_PUBLIC ${WRAPPER_LIBRARY_LINK_LIBRARIES})
itk_target_link_libraries_with_dynamic_lookup(${lib} LINK_PUBLIC ${PYTHON_LIBRARY})
itk_target_link_libraries_with_dynamic_lookup(${lib} LINK_PUBLIC ${Python3_LIBRARIES})

if(USE_COMPILER_HIDDEN_VISIBILITY)
# Prefer to use target properties supported by newer cmake
Expand Down

0 comments on commit 55c7b7f

Please sign in to comment.