From d039b6b36819c0e6e079293c84be122e796c6e16 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:35:37 -0500 Subject: [PATCH] Use component for python (#1643) * Add "COMPONENT python" to install() the python bindings and tell scikit-build-core to only install the python component Signed-off-by: Jean-Christophe Morin * Update scikit-build-core to 0.8.1 Signed-off-by: Jean-Christophe Morin * Fix typo Signed-off-by: Jean-Christophe Morin --------- Signed-off-by: Jean-Christophe Morin --- pyproject.toml | 9 ++++++++- src/wrappers/python/CMakeLists.txt | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fdc7b0370a..bd23df333a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ # Copyright (c) Contributors to the OpenEXR Project. [build-system] -requires = ["scikit-build-core==0.8.0"] +requires = ["scikit-build-core==0.8.1"] build-backend = "scikit_build_core.build" [project] @@ -27,7 +27,13 @@ test = ["pytest"] [tool.scikit-build] wheel.expand-macos-universal-tags = true sdist.exclude = [".github", "src/test", "src/examples", "website", "ASWF", "bazel", "share"] + +# Only build the PyOpenEXR (cmake --build --target PyOpenEXR). cmake.targets = ["PyOpenEXR"] +# Only install the "python" component (cmake --install --component python). +# This makes sure that only files marked as "python" component are installed. +install.components = ["python"] + # Enable experimental features if any are available # In this case we need custom local plugin to get # the project version from cmake. @@ -35,6 +41,7 @@ experimental = true metadata.version.provider = "openexr_skbuild_plugin" metadata.version.provider-path = "./src/wrappers/python" + [tool.scikit-build.cmake.define] OPENEXR_INSTALL = 'OFF' OPENEXR_BUILD_PYTHON = 'ON' diff --git a/src/wrappers/python/CMakeLists.txt b/src/wrappers/python/CMakeLists.txt index 471619b683..b240eb04a5 100644 --- a/src/wrappers/python/CMakeLists.txt +++ b/src/wrappers/python/CMakeLists.txt @@ -28,8 +28,8 @@ if(SKBUILD) set(PYTHON_INSTALL_DIR ${SKBUILD_PLATLIB_DIR}) endif() -install(TARGETS PyOpenEXR DESTINATION ${PYTHON_INSTALL_DIR}) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Imath.py DESTINATION ${PYTHON_INSTALL_DIR}) +install(TARGETS PyOpenEXR DESTINATION ${PYTHON_INSTALL_DIR} COMPONENT python) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Imath.py DESTINATION ${PYTHON_INSTALL_DIR} COMPONENT python) if(BUILD_TESTING AND OPENEXR_TEST_PYTHON)