Skip to content

Commit

Permalink
ENH: Add typehints to python wheel packages
Browse files Browse the repository at this point in the history
See https://peps.python.org/pep-0561/#stub-only-packages
Packaging typehints with package so use "itk", if making separate typehint
package use "itk-stubs"
set(ITK_STUB_BASENAME "itk")

The typehint files provide improved IDE introspection
capabilities for ITK.
  • Loading branch information
hjmjohnson committed Aug 23, 2022
1 parent 1ffdfd0 commit d7bb212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Wrapping/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ set(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
# Additional files for installation
###############################################################################

# See https://peps.python.org/pep-0561/#stub-only-packages
# Packaging typehints with package so use "itk", if making separate typehint
# package use "itk-stubs"
set(ITK_STUB_BASENAME "itk")
# 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.")
set(ITK_STUB_DIR "${ITK_DIR}/Wrapping/Generators/Python/${ITK_STUB_BASENAME}" 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
Expand Down
2 changes: 1 addition & 1 deletion Wrapping/Generators/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +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)
install(DIRECTORY ${ITK_STUB_DIR}/ DESTINATION ${PY_SITE_PACKAGES_PATH}/${ITK_STUB_BASENAME})
endif()


Expand Down

0 comments on commit d7bb212

Please sign in to comment.