Skip to content

Commit 922a87c

Browse files
Merge pull request #4 from KitwareMedical/slicer-core-sdk-based
Add SlicerCore compatibility
2 parents 08dc30a + 712dca8 commit 922a87c

46 files changed

Lines changed: 1148 additions & 241 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-wheels.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: build-wheels
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
description: "OS to run on, must be one of supported runner type"
8+
required: true
9+
type: string
10+
build-target:
11+
description: "CIBW build target (e.g., cp310-manylinux_x86_64)"
12+
required: true
13+
type: string
14+
python-version:
15+
description: "CIBW build target (e.g., 3.10)"
16+
required: true
17+
type: string
18+
platform-tag:
19+
description: "Wheel platform tag to apply after building."
20+
required: true
21+
type: string
22+
23+
jobs:
24+
build-test:
25+
runs-on: ${{ inputs.os }}
26+
27+
env:
28+
PIP_EXTRA_INDEX_URL: "https://vtk.org/files/wheel-sdks"
29+
CIBW_ENVIRONMENT_PASS_LINUX: "PIP_EXTRA_INDEX_URL"
30+
CIBW_BUILD: ${{ inputs.build-target }}
31+
# Required to make tests pass (VTK needs them)
32+
CIBW_BEFORE_ALL_LINUX: "yum install -y mesa-libGL-devel glx-utils freeglut-devel"
33+
# Global test setup
34+
CIBW_TEST_REQUIRES: "pytest virtualenv"
35+
# Do not repair, everything is already put just as needed to make it work
36+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "
37+
python -m pip install wheel &&
38+
python -m wheel tags --platform-tag ${{ inputs.platform-tag }} --remove {wheel} &&
39+
cp $(dirname {wheel})/slicer_layer_dm*.whl {dest_dir}"
40+
# same as above, we don't patch the wheel on Mac too.
41+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "
42+
python -m pip install wheel &&
43+
python -m wheel tags --platform-tag ${{ inputs.platform-tag }} --remove {wheel} &&
44+
cp $(dirname {wheel})/slicer_layer_dm*.whl {dest_dir}"
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ inputs.python-version }}
51+
# Required to use MSVC with Ninja
52+
- uses: ilammy/msvc-dev-cmd@v1.13.0
53+
54+
- name: Build wheel
55+
uses: pypa/cibuildwheel@v3.3.1
56+
env:
57+
CIBW_TEST_COMMAND: "python -m pytest {project}/LayerDM -m runtime --verbose"
58+
with:
59+
package-dir: LayerDM
60+
output-dir: wheelhouse
61+
62+
- name: Build wheel SDK
63+
uses: pypa/cibuildwheel@v3.3.1
64+
env:
65+
CIBW_TEST_COMMAND: "python -m pytest {project}/LayerDM -m sdk --verbose"
66+
with:
67+
package-dir: LayerDMSDK
68+
output-dir: wheelhouse
69+
70+
- name: Upload wheels
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: slicer_layer_md-${{ inputs.build-target }}
74+
path: |
75+
wheelhouse/slicer_layer_dm-*.whl
76+
wheelhouse/slicer_layer_dm_sdk-*.whl

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI Slicer Core
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
build-test:
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macos-latest]
13+
py-abi: ["cp310"]
14+
include:
15+
# Python version to install on host
16+
- py-abi: cp310
17+
python-version: "3.10"
18+
# OS name to ciwheelbuild platform name
19+
- os: ubuntu-latest
20+
platform-tag: manylinux_2_28_x86_64
21+
build-target: "manylinux_x86_64"
22+
- os: windows-latest
23+
platform-tag: win_amd64
24+
build-target: "win_amd64"
25+
- os: macos-latest
26+
platform-tag: macosx_11_0_arm64
27+
build-target: "macosx_arm64"
28+
uses: ./.github/workflows/build-wheels.yml
29+
with:
30+
os: ${{ matrix.os }}
31+
build-target: ${{ matrix.py-abi }}-${{ matrix.build-target }}
32+
python-version: ${{ matrix.python-version }}
33+
platform-tag: ${{ matrix.platform-tag }}

.github/workflows/commit-lint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Lint Commit Messages
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
pull-requests: read
7+
8+
jobs:
9+
commitlint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: wagoid/commitlint-github-action@v6

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
semantic-release:
7+
runs-on: ubuntu-latest
8+
environment:
9+
name: pypi
10+
url: https://pypi.org/p/trame-slicer
11+
permissions:
12+
id-token: write # IMPORTANT: mandatory for trusted publishing
13+
contents: write # IMPORTANT: mandatory for making GitHub Releases
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Python Semantic Release
22+
id: release
23+
uses: python-semantic-release/python-semantic-release@master
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
changelog: true
27+
build: false # build is too complex to be handled by semantic release
28+
29+
release-build:
30+
needs: [semantic-release]
31+
strategy:
32+
fail-fast: true
33+
matrix:
34+
os: [ubuntu-latest, windows-latest, macos-latest]
35+
py-abi: ["cp310", "cp311", "cp312", "cp313"]
36+
include:
37+
# Python version to install on host
38+
- py-abi: cp310
39+
python-version: "3.10"
40+
- py-abi: cp311
41+
python-version: "3.11"
42+
- py-abi: cp312
43+
python-version: "3.12"
44+
- py-abi: cp313
45+
python-version: "3.13"
46+
# OS name to ciwheelbuild platform name
47+
- os: ubuntu-latest
48+
platform-tag: manylinux_2_28_x86_64
49+
build-target: "manylinux_x86_64"
50+
- os: windows-latest
51+
platform-tag: win_amd64
52+
build-target: "win_amd64"
53+
- os: macos-latest
54+
platform-tag: macosx_11_0_arm64
55+
build-target: "macosx_arm64"
56+
uses: ./.github/workflows/build-wheels.yml
57+
with:
58+
os: ${{ matrix.os }}
59+
build-target: ${{ matrix.py-abi }}-${{ matrix.build-target }}
60+
python-version: ${{ matrix.python-version }}
61+
platform-tag: ${{ matrix.platform-tag }}
62+
63+
upload-pypi:
64+
name: Push runtime wheel on PyPi
65+
needs: [release-build]
66+
runs-on: ubuntu-latest
67+
environment:
68+
name: pypi
69+
url: https://pypi.org/p/slicer-layer-dm
70+
permissions:
71+
id-token: write # IMPORTANT: mandatory for trusted publishing
72+
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Download all wheel artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
path: ./wheelhouse
80+
pattern: slicer_layer_dm-*
81+
merge-multiple: true # Flattens them into one directory
82+
83+
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
84+
- name: Publish package distributions to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1
86+
with:
87+
packages-dir: ./wheelhouse
88+
89+
upload-pypi-sdk:
90+
name: Push SDK wheel on PyPi
91+
needs: [release-build]
92+
runs-on: ubuntu-latest
93+
environment:
94+
name: pypi
95+
url: https://pypi.org/p/slicer-layer-dm-sdk
96+
permissions:
97+
id-token: write # IMPORTANT: mandatory for trusted publishing
98+
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Download all wheel artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: ./wheelhouse
106+
pattern: slicer_layer_dm_sdk-*
107+
merge-multiple: true # Flattens them into one directory
108+
109+
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
110+
- name: Publish package distributions to PyPI
111+
uses: pypa/gh-action-pypi-publish@release/v1
112+
with:
113+
packages-dir: ./wheelhouse

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
/Docs/api/
55
/Docs/doxygen/
66
/node_modules/
7+
8+
venv/
9+
*.whl

CMakeLists.txt

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
cmake_minimum_required(VERSION 3.16.3...3.19.7 FATAL_ERROR)
1+
# CMake will complain if this is not in this file specifically
2+
cmake_minimum_required(VERSION 3.16.3...4.0)
23

3-
project(LayerDisplayableManager)
4+
# Most CMakeLists.txt files in this repo will have this conditional structure
5+
# SlicerLayerDM can be built in two different ways:
6+
# - A 3DSlicer extension
7+
# - A slicer-core based python wheel
8+
# Using include like this enables the CMake code to be in the expected
9+
# source/binary directory and add_subdirectory to work seamlessly
10+
if(DEFINED SKBUILD_PROJECT_NAME)
11+
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION})
12+
include(${CMAKE_CURRENT_SOURCE_DIR}/wheel.cmake)
13+
else()
14+
project(LayerDisplayableManager)
415

5-
#-----------------------------------------------------------------------------
6-
# Extension meta-information
7-
set(EXTENSION_HOMEPAGE "https://github.com/KitwareMedical/SlicerLayerDisplayableManager")
8-
set(EXTENSION_CONTRIBUTORS "Thibault Pelletier (Kitware SAS)")
9-
set(EXTENSION_DESCRIPTION "A 3D Slicer module introducing a new displayable manager architecture for layered rendering and interaction handling.")
10-
set(EXTENSION_ICONURL "https://github.com/KitwareMedical/SlicerLayerDisplayableManager/raw/main/Docs/LayerDisplayableManager.png")
11-
set(EXTENSION_SCREENSHOTURLS "https://github.com/KitwareMedical/SlicerLayerDisplayableManager/raw/main/Docs/LayeredDisplayableManager_UML.jpg")
12-
set(EXTENSION_DEPENDS "NA") # Specified as a list or "NA" if no dependencies
16+
# disable https://cmake.org/cmake/help/latest/policy/CMP0148.html as vtkAddon may need it
17+
if(POLICY CMP0148)
18+
cmake_policy(SET CMP0148 OLD)
19+
endif()
1320

14-
#-----------------------------------------------------------------------------
15-
# Extension dependencies
16-
find_package(Slicer REQUIRED)
17-
include(${Slicer_USE_FILE})
18-
19-
#-----------------------------------------------------------------------------
20-
# Extension modules
21-
add_subdirectory(LayerDM)
22-
23-
#-----------------------------------------------------------------------------
24-
include(${Slicer_EXTENSION_GENERATE_CONFIG})
25-
include(${Slicer_EXTENSION_CPACK})
21+
include(${CMAKE_CURRENT_SOURCE_DIR}/extension.cmake)
22+
endif()

LayerDM/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Note: this file is never included when building the slicer-core based version
12

23
#-----------------------------------------------------------------------------
34
set(MODULE_NAME LayerDM)

LayerDM/Logic/CMakeLists.txt

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,5 @@
1-
project(vtkSlicer${MODULE_NAME}ModuleLogic)
2-
3-
set(KIT ${PROJECT_NAME})
4-
set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_LOGIC_EXPORT")
5-
set(${KIT}_INCLUDE_DIRECTORIES)
6-
7-
set(LayerDM_VERSION_MAJOR 1)
8-
set(LayerDM_VERSION_MINOR 1)
9-
set(LayerDM_VERSION_PATCH 0)
10-
set(LayerDM_VERSION "${LayerDM_VERSION_MAJOR}.${LayerDM_VERSION_MINOR}.${LayerDM_VERSION_PATCH}")
11-
12-
configure_file(
13-
${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerLayerDMVersion.h.in
14-
${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMVersion.h
15-
@ONLY
16-
)
17-
18-
set(${KIT}_SRCS
19-
vtkSlicer${MODULE_NAME}Logic.cxx
20-
vtkSlicer${MODULE_NAME}Logic.h
21-
)
22-
23-
set(${KIT}_TARGET_LIBRARIES
24-
vtkSlicer${MODULE_NAME}ModuleMRML
25-
SlicerBaseLogic
26-
)
27-
28-
#-----------------------------------------------------------------------------
29-
SlicerMacroBuildModuleLogic(
30-
NAME ${KIT}
31-
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
32-
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
33-
SRCS ${${KIT}_SRCS}
34-
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
35-
)
36-
37-
target_include_directories(
38-
${KIT}
39-
PUBLIC
40-
${${KIT}_SOURCE_DIR}
41-
${${KIT}_BINARY_DIR}
42-
${Slicer_Base_INCLUDE_DIRS}
43-
)
1+
if(DEFINED SKBUILD_PROJECT_NAME)
2+
include(${CMAKE_CURRENT_SOURCE_DIR}/wheel.cmake)
3+
else()
4+
include(${CMAKE_CURRENT_SOURCE_DIR}/extension.cmake)
5+
endif()

LayerDM/Logic/extension.cmake

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(vtkSlicer${MODULE_NAME}ModuleLogic)
3+
4+
set(KIT ${PROJECT_NAME})
5+
set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_LOGIC_EXPORT")
6+
set(${KIT}_INCLUDE_DIRECTORIES)
7+
8+
configure_file(
9+
${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerLayerDMVersion.h.in
10+
${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMVersion.h
11+
@ONLY
12+
)
13+
14+
set(${KIT}_SRCS
15+
vtkSlicer${MODULE_NAME}Logic.cxx
16+
vtkSlicer${MODULE_NAME}Logic.h
17+
${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMModuleLogicModule.h
18+
)
19+
20+
set(${KIT}_TARGET_LIBRARIES
21+
vtkSlicer${MODULE_NAME}ModuleMRML
22+
SlicerBaseLogic
23+
)
24+
25+
#-----------------------------------------------------------------------------
26+
SlicerMacroBuildModuleLogic(
27+
NAME ${KIT}
28+
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
29+
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
30+
SRCS ${${KIT}_SRCS}
31+
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
32+
)
33+
34+
include(GenerateExportHeader)
35+
generate_export_header(${KIT}
36+
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMModuleLogicModule.h
37+
EXPORT_MACRO_NAME ${${KIT}_EXPORT_DIRECTIVE}
38+
)
39+
40+
target_include_directories(
41+
${KIT}
42+
PUBLIC
43+
${${KIT}_SOURCE_DIR}
44+
${${KIT}_BINARY_DIR}
45+
${Slicer_Base_INCLUDE_DIRS}
46+
)

0 commit comments

Comments
 (0)