-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for packaging VTK SDK as a wheel
This pulls a tar.xz archive from https://vtk.org/files/wheel-sdks and package it as a wheel using scikit-build-core. This wheel will then be added to a pip repository to be fetch through build requirements.
- Loading branch information
1 parent
1adb2c5
commit 3b56e25
Showing
9 changed files
with
77 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,61 @@ | ||
cmake_minimum_required(VERSION 3.15...3.26) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX) | ||
cmake_minimum_required(VERSION 3.21) | ||
|
||
set(PYBIND11_FINDPYTHON ON) | ||
find_package(pybind11 CONFIG REQUIRED) | ||
set(VTK_VERSION | ||
"9.2.6" | ||
CACHE STRING "VTK SDK version to package") | ||
project( | ||
vtk-sdk | ||
VERSION ${VTK_VERSION} | ||
DESCRIPTION "VTK SDK python distributions" | ||
HOMEPAGE_URL "https://github.com/Kitware/vtk-sdk-python-distributions" | ||
LANGUAGES NONE) | ||
|
||
pybind11_add_module(_core MODULE src/main.cpp) | ||
install(TARGETS _core DESTINATION ${SKBUILD_PROJECT_NAME}) | ||
find_package( | ||
Python | ||
COMPONENTS Interpreter Development.Module | ||
REQUIRED) | ||
|
||
include(cmake/vtk-sdk-urls.cmake) | ||
include(FetchContent) | ||
|
||
set(download_dir ${PROJECT_BINARY_DIR}) | ||
set(extract_dir ${PROJECT_BINARY_DIR}/vtk-wheel-sdk) | ||
# FetchContent will download and extract our archive! | ||
FetchContent_Populate( | ||
vtkwheelsdk | ||
URL ${VTK_SDK_BINARY_URL} DOWNLOAD_DIR ${download_dir} | ||
SOURCE_DIR ${extract_dir}) | ||
|
||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/vtk-config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/vtk_sdk/cmake/vtk-config.cmake @ONLY) | ||
|
||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/vtk-config-version.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/vtk_sdk/cmake/vtk-config-version.cmake @ONLY) | ||
|
||
# "/" after ${extract_dir} is required so the folder content is copied to dest, | ||
# instead of the folder itself! | ||
install( | ||
DIRECTORY ${extract_dir}/ | ||
DESTINATION vtk_sdk | ||
PATTERN "bin/*" EXCLUDE) | ||
|
||
install( | ||
DIRECTORY ${extract_dir}/bin/ | ||
DESTINATION vtk_sdk/bin | ||
PATTERN | ||
"*" | ||
PERMISSIONS | ||
OWNER_READ | ||
OWNER_WRITE | ||
OWNER_EXECUTE | ||
GROUP_READ | ||
GROUP_EXECUTE | ||
WORLD_READ | ||
WORLD_EXECUTE) | ||
|
||
install( | ||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vtk_sdk/cmake/__init__.py | ||
${CMAKE_CURRENT_BINARY_DIR}/vtk_sdk/cmake/vtk-config.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/vtk_sdk/cmake/vtk-config-version.cmake | ||
DESTINATION vtk_sdk/cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include(${CMAKE_CURRENT_LIST_DIR}/../vtk-@[email protected]/headers/cmake/vtk-config-version.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include(${CMAKE_CURRENT_LIST_DIR}/../vtk-@[email protected]/headers/cmake/vtk-config.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# VTK SDK is currently stored as a tar.xz archive on a Kitware hosted server | ||
set(python_cp "cp${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") | ||
|
||
# enable any linux to download the right tar.xz | ||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
set(VTK_SDK_BINARY_URL | ||
"https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-${VTK_VERSION}-${python_cp}-${python_cp}-manylinux_2_17_x86_64.manylinux2014_x86_64.tar.xz" | ||
) | ||
else() | ||
set(VTK_SDK_BINARY_URL | ||
"https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-${VTK_VERSION}-${python_cp}-${Python_SOABI}.tar.xz" | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# This module is here because the path of the actual vtk-config.cmake file is not a valid module name |
This file was deleted.
Oops, something went wrong.