@@ -258,4 +258,30 @@ install(TARGETS PyOpenColorIO
258258 LIBRARY DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR}
259259)
260260
261- install (FILES package/__init__.py DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR} )
261+ install (FILES stubs/PyOpenColorIO/__init__.pyi DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR} )
262+ install (FILES stubs/PyOpenColorIO/py.typed DESTINATION ${_PyOpenColorIO_SITE_PACKAGE_DIR} )
263+
264+ ###############################################################################
265+
266+ # Note: the python version must be kept in sync with `[[tool.cibuildwheel.overrides]]` in pyproject.toml.
267+ # The stubs are generated within a container so the version of python does not need to match
268+ # the version of python that OpenColorIO is being built against.
269+ # Note: the version of cibuildwheel should be kept in sync with .github/workflows/wheel.yml
270+ add_custom_command (COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR} /src/bindings/python/stubs/generate_stubs_local.py
271+ --repo-root ${CMAKE_SOURCE_DIR} --python-version ="3.11" --cibuildwheel-version ="2.22.0"
272+ --output -dir "${CMAKE_BINARY_DIR} /wheelhouse"
273+ OUTPUT "${CMAKE_BINARY_DIR} /wheelhouse/PyOpenColorIO/__init__.pyi"
274+ DEPENDS "${CMAKE_SOURCE_DIR} /src/bindings/python/stubs/generate_stubs.py"
275+ DEPENDS "${CMAKE_SOURCE_DIR} /src/bindings/python/stubs/generate_stubs_local.py"
276+ COMMENT "pystubs: Generating python stubs"
277+ )
278+
279+ add_custom_command (COMMAND ${CMAKE_COMMAND} -E copy
280+ "${CMAKE_BINARY_DIR} /wheelhouse/PyOpenColorIO/__init__.pyi"
281+ "${CMAKE_SOURCE_DIR} /src/bindings/python/stubs/PyOpenColorIO/__init__.pyi"
282+ OUTPUT "${CMAKE_SOURCE_DIR} /src/bindings/python/stubs/PyOpenColorIO/__init__.pyi"
283+ DEPENDS "${CMAKE_BINARY_DIR} /wheelhouse/PyOpenColorIO/__init__.pyi"
284+ COMMENT "pystubs: Copying generated stubs to source"
285+ )
286+
287+ add_custom_target (pystubs DEPENDS "${CMAKE_SOURCE_DIR} /src/bindings/python/stubs/PyOpenColorIO/__init__.pyi" )
0 commit comments