Skip to content

Commit

Permalink
build(wheel): Only install Py module, libs, fonts, oiiotool and maketx
Browse files Browse the repository at this point in the history
The installation components have been limited to 'user' and 'fonts'. No development headers or config files are included.

Also, only `oiiotool` and `maketx` are built and exposed as Python scripts (when building with pip).

Signed-off-by: Zach Lewis <[email protected]>
  • Loading branch information
zachlewis committed Oct 30, 2024
1 parent 3524c4f commit babfa59
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 27 deletions.
24 changes: 2 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ Issues = "https://github.com/AcademySoftwareFoundation/OpenImageIO/issues"

[project.scripts]
# Use the convention below to expose CLI tools as Python scripts.
iconvert = "OpenImageIO:_command_line"
idiff = "OpenImageIO:_command_line"
igrep = "OpenImageIO:_command_line"
iinfo = "OpenImageIO:_command_line"
maketx = "OpenImageIO:_command_line"
oiiotool = "OpenImageIO:_command_line"
testtex = "OpenImageIO:_command_line"

[build-system]
build-backend = "scikit_build_core.build"
Expand All @@ -65,6 +60,8 @@ cmake.version = "CMakeLists.txt"
wheel.license-files = ["LICENSE.md", "THIRD-PARTY.md"]
# Make sure the package is structured as expected.
wheel.install-dir = "OpenImageIO"
# Only install the user and fonts components.
install.components = ["user", "fonts"]

[tool.scikit-build.cmake.define]
# Build missing dependencies. See src/cmake for details.
Expand Down Expand Up @@ -97,23 +94,6 @@ if.platform-machine = "x86_64"
inherit.cmake.define = "append"
cmake.define.CMAKE_OSX_ARCHITECTURES = "x86_64"

# Provide CMAKE_PREFIX_PATH hint for downstream scikit-build-based projets
# See https://scikit-build-core.readthedocs.io/en/latest/cmakelists.html#finding-other-packages
[project.entry-points."cmake.prefix"]
any = "OpenImageIO.lib.cmake.OpenImageIO"

# Touch a few __init__.py files so the above entry-point is recognized.
[[tool.scikit-build.generate]]
path = "OpenImageIO/lib/__init__.py"
template = " "

[[tool.scikit-build.generate]]
path = "OpenImageIO/lib/cmake/__init__.py"
template = " "

[[tool.scikit-build.generate]]
path = "OpenImageIO/lib/cmake/OpenImageIO/__init__.py"
template = " "

[tool.cibuildwheel]
build-verbosity = 1
Expand Down
4 changes: 2 additions & 2 deletions src/cmake/dependency_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ macro (install_local_dependency_libs pkgname libname)
"${${pkgname}_LOCAL_INSTALL_DIR}/lib/*${libname}*"
"${${pkgname}_LOCAL_INSTALL_DIR}/lib/${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE}/*${libname}*"
)
install (FILES ${_lib_files} TYPE LIB)
install (FILES ${_lib_files} TYPE LIB COMPONENT user)
# message("${pkgname}_LOCAL_INSTALL_DIR = ${${pkgname}_LOCAL_INSTALL_DIR}")
# message(" lib files = ${_lib_files}")
if (WIN32)
Expand All @@ -680,7 +680,7 @@ macro (install_local_dependency_libs pkgname libname)
"${${pkgname}_LOCAL_INSTALL_DIR}/bin/${${PROJECT_NAME}_DEPENDENCY_BUILD_TYPE}/*${libname}*.dll"
)
# message(" dll files = ${_lib_files}")
install (FILES ${_lib_files} TYPE BIN)
install (FILES ${_lib_files} TYPE BIN COMPONENT user)
endif ()
unset (_lib_files)
endmacro ()
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/pythonutils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ macro (setup_python_module)
RUNTIME DESTINATION ${PYTHON_SITE_DIR} COMPONENT user
LIBRARY DESTINATION ${PYTHON_SITE_DIR} COMPONENT user)

install(FILES __init__.py DESTINATION ${PYTHON_SITE_DIR})
install(FILES __init__.py DESTINATION ${PYTHON_SITE_DIR} COMPONENT user)

endmacro ()

7 changes: 6 additions & 1 deletion src/iconvert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

fancy_add_executable (LINK_LIBRARIES OpenImageIO)
# Don't build if installing as a Python wheel
if (SKBUILD)
return ()
endif ()

fancy_add_executable (LINK_LIBRARIES OpenImageIO)
7 changes: 6 additions & 1 deletion src/idiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

fancy_add_executable (LINK_LIBRARIES OpenImageIO)
# Don't build if installing as a Python wheel
if (SKBUILD)
return ()
endif ()

fancy_add_executable (LINK_LIBRARIES OpenImageIO)
5 changes: 5 additions & 0 deletions src/igrep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

# Don't build if installing as a Python wheel
if (SKBUILD)
return ()
endif ()

fancy_add_executable (LINK_LIBRARIES OpenImageIO)
5 changes: 5 additions & 0 deletions src/iinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

# Don't build if installing as a Python wheel
if (SKBUILD)
return ()
endif ()

fancy_add_executable (LINK_LIBRARIES OpenImageIO)
6 changes: 6 additions & 0 deletions src/iv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

set (OIIO_IV_EXTRA_IV_LIBRARIES "" CACHE STRING "Paths to extra libraries to force iv to link against")


# Don't build if installing as a Python wheel
if (SKBUILD)
return ()
endif ()

set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTOMOC_PATH_PREFIX OFF)
if (Qt5_POSITION_INDEPENDENT_CODE OR Qt6_POSITION_INDEPENDENT_CODE)
Expand Down
4 changes: 4 additions & 0 deletions src/testtex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# be local to this directory and not override properly by command line `-D`.)
set (ENABLE_INSTALL_testtex OFF PARENT_SCOPE)

if (SKBUILD)
return ()
endif ()

fancy_add_executable (NAME testtex
INCLUDE_DIRS ${ROBINMAP_INCLUDES}
LINK_LIBRARIES OpenImageIO )

0 comments on commit babfa59

Please sign in to comment.