Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,74 @@ jobs:
name: cibw-sdist
path: dist/*.tar.gz

test_sdist:
name: Test SDist with python ${{ matrix.python }}
needs: [make_sdist]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python ${{ matrix.python }}
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
pip install pytest pytest-cov

- uses: actions/download-artifact@v4
with:
name: cibw-sdist
path: dist

- name: Install SDist
run: |
pip -V
pip install dist/*.tar.gz
rm -rf dist

- name: Test installed SDist
run: pytest ./tests

check_dist:
name: Check dist
needs: [build_wheels, make_sdist, test_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: all

- run: pipx run twine check --strict all/*/*

build_wheels:
name: Wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
arch: ["auto"]

include:
- os: macos-14
arch: "arm64"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pypa/[email protected]
env:
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-*"
CIBW_ARCHS: "${{ matrix.arch }}"
CIBW_REPAIR_WHEEL_COMMAND: ""

- name: Upload wheels
uses: actions/upload-artifact@v4
Expand All @@ -52,7 +106,7 @@ jobs:
path: wheelhouse/*.whl

upload_all:
needs: [build_wheels, make_sdist]
needs: [check_dist]
environment: pypi
permissions:
id-token: write
Expand All @@ -67,7 +121,3 @@ jobs:
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/
37 changes: 32 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]

include:
- python-version: pypy-3.10
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -69,3 +65,34 @@ jobs:
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

checks-cibw:
name: >
Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} (${{
matrix.arch }})
runs-on: ${{ matrix.runs-on }}
needs: [pre-commit]
strategy:
fail-fast: false
matrix:
include:
- runs-on: macos-14
python-version: cp39
arch: "arm64"
- runs-on: macos-14
python-version: cp310
arch: "arm64"
- runs-on: macos-14
python-version: cp311
arch: "arm64"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pypa/[email protected]
env:
CIBW_BUILD: "${{ matrix.python-version }}-*"
CIBW_ARCHS: "${{ matrix.arch }}"
CIBW_REPAIR_WHEEL_COMMAND: ""
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ repos:
args: []
additional_dependencies:
- pytest
- virtualenv

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
Expand Down
66 changes: 60 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,62 @@
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.5")

pybind11_add_module(_core MODULE src/main.cpp)
install(TARGETS _core DESTINATION ${SKBUILD_PROJECT_NAME})
project(
vtk-sdk
VERSION ${VTK_VERSION}
DESCRIPTION "VTK SDK python distributions"
HOMEPAGE_URL "https://github.com/Kitware/vtk-sdk-python-distributions"
LANGUAGES NONE)

find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED)

# ----------------------------------------------------------------------------
# Download and extract vtk-wheel-sdk archive

include(cmake/download-vtk-sdk.cmake)

# ----------------------------------------------------------------------------
# Install content of the vtk-wheel-sdk archive

set(VTK_SDK_INSTALL_DIR "content")

# Append "/" after ${extract_dir} to ensure folder content is copied to the
# destination, instead of the folder itself.
install(
DIRECTORY ${extract_dir}/
DESTINATION vtk_sdk/${VTK_SDK_INSTALL_DIR}
PATTERN "bin/*" EXCLUDE)

install(
DIRECTORY ${extract_dir}/bin/
DESTINATION vtk_sdk/${VTK_SDK_INSTALL_DIR}/bin
PATTERN
"*"
PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE)

# ----------------------------------------------------------------------------
# Configure and install "cmake.prefix" entry point files

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)

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)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ distributed-memory parallel processing for scalability and better performance.
This project is intended to distribute the content of the existing VTK wheel
SDKs as first-class `vtk-sdk` wheels.

Each `vtk-sdk` Python wheel is equipped with a scikit-build-core `cmake-module`
Each `vtk-sdk` Python wheel is equipped with a scikit-build-core `cmake.prefix`
[entrypoint][scikit-build-core-entrypoint], housing the official VTK SDK sourced
from the corresponding [archive][wheel-sdks-link].

Expand Down
57 changes: 57 additions & 0 deletions cmake/download-vtk-sdk.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
message(STATUS "Setting VTK_SDK_BINARY_URL")

# Python and ABI tags
set(python_abi_name "cp${Python_VERSION_MAJOR}${Python_VERSION_MINOR}")
set(PYTHON_ABI_TAG "${python_abi_name}-${python_abi_name}")
include(${CMAKE_CURRENT_LIST_DIR}/vtk-sdk-urls.cmake)

# Platform tag
if(LINUX)
if(Python_SOABI MATCHES "x86_64")
set(plaform_name "linux_x86_64")
elseif(Python_SOABI MATCHES "arm64")
set(plaform_name "linux_arm64")
else()
message(FATAL_ERROR "Unsupported SOABI [${Python_SOABI}]")
endif()
elseif(APPLE)
set(plaform_name "macosx_x86_64")
if(Python_SOABI MATCHES "arm64")
set(plaform_name "macosx_arm64")
endif()
elseif(WIN32)
set(plaform_name "win_x86_64")
if(Python_SOABI MATCHES "arm64")
set(plaform_name "win_arm64")
endif()
else()
message(
FATAL_ERROR
"Failed to set plaform_tag based of Python_SOABI [${Python_SOABI}]")
endif()

# URL and SHA256
set(VTK_SDK_BINARY_URL ${${plaform_name}_url})
message(STATUS "Setting VTK_SDK_BINARY_URL: ${VTK_SDK_BINARY_URL}")

set(VTK_SDK_EXPECTED_SHA256 ${${plaform_name}_sha256})
message(STATUS "Setting VTK_SDK_EXPECTED_SHA256: ${VTK_SDK_EXPECTED_SHA256}")

if(NOT DEFINED VTK_SDK_BINARY_URL OR NOT DEFINED VTK_SDK_EXPECTED_SHA256)
message(FATAL_ERROR "Unsupported platform ${plaform_name}")
endif()

if(${VTK_SDK_BINARY_URL} STREQUAL "NOTFOUND" OR ${VTK_SDK_EXPECTED_SHA256} STREQUAL "NOTFOUND")
message(FATAL_ERROR "Unsupported platform ${plaform_name}")
endif()

set(download_dir ${PROJECT_BINARY_DIR})
set(extract_dir ${PROJECT_BINARY_DIR}/vtk-wheel-sdk)

include(FetchContent)
FetchContent_Populate(
vtkwheelsdk
URL ${VTK_SDK_BINARY_URL}
URL_HASH SHA256=${VTK_SDK_EXPECTED_SHA256}
DOWNLOAD_DIR ${download_dir}
SOURCE_DIR ${extract_dir})
1 change: 1 addition & 0 deletions cmake/vtk-config-version.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/../@VTK_SDK_INSTALL_DIR@/vtk-@[email protected]/headers/cmake/vtk-config-version.cmake)
1 change: 1 addition & 0 deletions cmake/vtk-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/../@VTK_SDK_INSTALL_DIR@/vtk-@[email protected]/headers/cmake/vtk-config.cmake)
56 changes: 56 additions & 0 deletions cmake/vtk-sdk-urls.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

if(${PYTHON_ABI_TAG} STREQUAL "cp38-cp38")
set(linux_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.tar.xz")
set(linux_x86_64_sha256 "f67ab5114eeccda490bd5a7ab8e6921e0b59d51489e7f47eb0ebc7f18e7cbd93")

set(macosx_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp38-cp38-macosx_10_10_x86_64.tar.xz")
set(macosx_x86_64_sha256 "a97438851a029fc3e9a630261a101001f5fc2edae45710f1cb0cde2dd2899334")

set(macosx_arm64_url "NOTFOUND")
set(macosx_arm64_sha256 "NOTFOUND")

set(win_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp38-cp38-win_amd64.tar.xz")
set(win_x86_64_sha256 "306360396efa3cffb03ecda75c4df84a89ededf05d0adfda4894d80adf2542ec")
endif()

if(${PYTHON_ABI_TAG} STREQUAL "cp39-cp39")
set(linux_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.tar.xz")
set(linux_x86_64_sha256 "8199f0cff9a43831eadeba0e4d89421c947002c53c030c50edb50312bb0726cd")

set(macosx_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp39-cp39-macosx_10_10_x86_64.tar.xz")
set(macosx_x86_64_sha256 "6a63d28a726188194fa7858d33645f43ea9ef21e696b8da91cc0536cf4c9131a")

set(macosx_arm64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp39-cp39-macosx_11_0_arm64.tar.xz")
set(macosx_arm64_sha256 "3747b3448b1ae0f511a389f82398a1ec5a883189ed01ed35c870ef746096ec6d")

set(win_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp39-cp39-win_amd64.tar.xz")
set(win_x86_64_sha256 "befbbea3bfc8584c5dd3b2c04b5ce7273eeb4581a5586adf10cb35b859609026")
endif()

if(${PYTHON_ABI_TAG} STREQUAL "cp310-cp310")
set(linux_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.tar.xz")
set(linux_x86_64_sha256 "79f8a8c6caf9d98aef29426637ea9eb9228682072dfa5b69bb97dc3baa2e93d7")

set(macosx_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp310-cp310-macosx_10_10_x86_64.tar.xz")
set(macosx_x86_64_sha256 "a0d37d8f93521753cb3bed8da3548f9f6c1f45cee493070b5dcc3801f62b33e5")

set(macosx_arm64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp310-cp310-macosx_11_0_arm64.tar.xz")
set(macosx_arm64_sha256 "99120ac6448907865b1feb95be4111992d2d511954d2c381bd5299ec87c6f76c")

set(win_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp310-cp310-win_amd64.tar.xz")
set(win_x86_64_sha256 "b85c5d48e6c36082c590276dd34458e5238cea7ae37156b5b30a2ca3e133d2b9")
endif()

if(${PYTHON_ABI_TAG} STREQUAL "cp311-cp311")
set(linux_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.tar.xz")
set(linux_x86_64_sha256 "dcd452e018b3a5a7a0b5dfab8e38af2ddbd0e0e387b1a8488b4516354c4a30fb")

set(macosx_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp311-cp311-macosx_10_10_x86_64.tar.xz")
set(macosx_x86_64_sha256 "f0bf60a0c740b9c92bb0f35cadb1f0c38d23b3994bdf24295ac986761dc6e59c")

set(macosx_arm64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp311-cp311-macosx_11_0_arm64.tar.xz")
set(macosx_arm64_sha256 "d2948347e7c803d8e691b48d58dd057ddb2265baf603eb0d7036a71a538e037d")

set(win_x86_64_url "https://vtk.org/files/wheel-sdks/vtk-wheel-sdk-9.2.5-cp311-cp311-win_amd64.tar.xz")
set(win_x86_64_sha256 "f70dca96484ba357fad52ce4d998b6480e5717e7e1d0f707f20c494c41d7a00e")
endif()
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = []
test = [
"pytest >=6",
"pytest-cov >=3",
"virtualenv",
]
dev = [
"pytest >=6",
Expand All @@ -56,12 +57,15 @@ Homepage = "https://github.com/Kitware/vtk-sdk-python-distributions"
Discussions = "https://github.com/Kitware/vtk-sdk-python-distributions/discussions"
Changelog = "https://github.com/Kitware/vtk-sdk-python-distributions/releases"

[project.entry-points."cmake.prefix"]
any = "vtk_sdk.cmake"

[tool.scikit-build]
minimum-version = "0.8.2"
build-dir = "build/{wheel_tag}"
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/vtk_sdk/_version.py"]
wheel.packages = ["src/vtk_sdk"]


[tool.setuptools_scm]
Expand Down
Loading