Skip to content

Commit

Permalink
ENH: Provide install of itk-stub pyi files
Browse files Browse the repository at this point in the history
ITK needs to also install the stub files for providing
type hints to IDE's.
  • Loading branch information
hjmjohnson committed Aug 19, 2022
1 parent 6022bb3 commit a8b0df7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 0 additions & 4 deletions CMake/WrappingConfigCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ if(ITK_WRAPPING)
# create the directory to avoid losing case on windows
file(MAKE_DIRECTORY ${ITK_WRAP_PYTHON_ROOT_BINARY_DIR})

set(ITK_STUB_DIR "${ITK_WRAP_PYTHON_ROOT_BINARY_DIR}/itk-stubs")
file(MAKE_DIRECTORY ${ITK_STUB_DIR})
install(DIRECTORY ${ITK_STUB_DIR}/ DESTINATION itk-stubs)

set(ITK_PYTHON_PACKAGE_DIR "${ITK_WRAP_PYTHON_ROOT_BINARY_DIR}/itk")
# create the directory to avoid losing case on windows
file(MAKE_DIRECTORY ${ITK_PYTHON_PACKAGE_DIR})
Expand Down
3 changes: 3 additions & 0 deletions Wrapping/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ set(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})

# ITK_STUB_DIR: all stub files are stored in this directory
set(ITK_STUB_DIR "${ITK_DIR}/Wrapping/Generators/Python/itk-stubs" CACHE INTERNAL "where python interface files are stored.")
file(MAKE_DIRECTORY ${ITK_STUB_DIR})

# ITK_PKL_DIR: all temporary pickled object AST representations stored here
set(ITK_PKL_DIR "${ITK_DIR}/Wrapping/Generators/Python/itk-pkl" CACHE INTERNAL "where temp pkl files are stored")
file(MAKE_DIRECTORY ${ITK_PKL_DIR})
set(WRAP_ITK_TYPEDEFS_DIRECTORY "${ITK_DIR}/Wrapping/Typedefs")
set(WRAP_ITK_LIB_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

Expand Down
6 changes: 4 additions & 2 deletions Wrapping/Generators/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ if(Python3_EXECUTABLE AND NOT PY_SITE_PACKAGES_PATH)
endif()
string(REGEX REPLACE "\n" "" py_spp_no_newline "${py_spp}")
file(TO_CMAKE_PATH "${py_spp_no_newline}" py_spp_nobackslashes)

set(PY_SITE_PACKAGES_PATH "${py_spp_nobackslashes}" CACHE STRING "Python site-packages directory to install Python bindings.")
mark_as_advanced(PY_SITE_PACKAGES_PATH)
endif()

set(PY_SITE_PACKAGES_PATH "${py_spp_nobackslashes}" CACHE STRING "Python site-packages directory to install Python bindings.")
mark_as_advanced(PY_SITE_PACKAGES_PATH)
if(NOT PY_SITE_PACKAGES_PATH)
message(SEND_ERROR "Please set PY_SITE_PACKAGES_PATH to the Python bindings installation directory.")
endif()
Expand Down Expand Up @@ -180,6 +181,7 @@ if(NOT EXTERNAL_WRAP_ITK_PROJECT)
WRAP_ITK_PYTHON_BINDINGS_INSTALL(/itk/support "ITKCommon" ${ITK_WRAP_PYTHON_FILES})
WRAP_ITK_PYTHON_BINDINGS_INSTALL(/itk/Configuration "ITKCommon" "${ITK_CONFIGURATION_INIT_MODULE}")
WRAP_ITK_PYTHON_BINDINGS_INSTALL(/itk "ITKCommon" ${ITK_INIT_MODULE})
install(DIRECTORY ${ITK_STUB_DIR}/ DESTINATION ${PY_SITE_PACKAGES_PATH}/itk-stubs)
endif()


Expand Down

0 comments on commit a8b0df7

Please sign in to comment.