SlicerCore (formally known as VTK MRML), is an alternative build-system for the 3DSlicer project that is intended to build a Python Package (wheel) from the core libraries of 3DSlicer (a.k.a MRML).
SlicerCore repository only contains patches against a known version of Slicer.
SlicerCore patches replaces 3DSlicer build system (CMakeLists.txt), introduces vtk.module files.
There are a small amount of modification done on the C++ code too, but the goal is to do the minimum amount of changes in it.
Patches are generated from my (Alexy Pellegrini) fork
using the SlicerCore/generate_patch.py script on said fork.
Patches are then applied on the same revision using the apply_patch.py (on this repo).
This creates a source tree: ./Slicer that contains the patched Slicer ready to be built.
They are used to bootstrap the Slicer patched repository:
python ./apply_patch.pyThis will create a "Slicer" folder that is freshly cloned from information stored in common.py, and with all the patch applied.
Options step, change target VTK version, by default, the version is set to some value in the pyproject.toml files.
python ./set_vtk_version.py <desired-version>To build slicer-core wheel:
python -m pip wheel Slicer/SlicerCore --extra-index-url https://vtk.org/files/wheel-sdksTo build slicer-core-sdk wheel:
python -m pip wheel Slicer/SlicerCoreSDK --extra-index-url https://vtk.org/files/wheel-sdksTo run SlicerCoreSDK tests:
python -m pytest Slicer/SlicerCoreNote that SlicerCoreSDK tests will by default build SlicerCore and SlicerCoreSDK from scratch, and that takes about an hour even on a decent hardware. An optional option is supported by the tests: --local-wheels, so you can built the wheels then test them without any additional build.
Typical workflow would be:
# Install build deps
python -m pip install virtualenv pytest
# Build the two wheels
python -m pip wheel Slicer/SlicerCore --wheel-dir wheelhouse --extra-index-url https://vtk.org/files/wheel-sdks
python -m pip wheel Slicer/SlicerCoreSDK --wheel-dir wheelhouse --extra-index-url https://vtk.org/files/wheel-sdks
# Test them
python -m pytest Slicer/SlicerCore --local-wheels wheelhouseSlicerCore and its SDK can not be patched using the classic auditwheel, delvewheel or relocate.
Everything is already patched and installed as needed by the CMake code.
To have a wheel that is properly tagged, force the tag of the building OS:
python -m pip install wheel
python -m wheel tags --platform-tag <your-platform> --remove wheelhouse/slicer_core-*.whl
python -m wheel tags --platform-tag <your-platform> --remove wheelhouse/slicer_core_sdk-*.whlThis step is only needed on Linux and Mac.
apply_patch.py will commit all the changes into an autogenerated commit, so it is ready to rebase.
cd Slicer
git rebase <revision>Then resolve potential conflicts.
Check the following:
- Is there any new classes in Slicer? If so, add them to the modules classes list.
- Run build and tests (see above), if anything breaks, fix it then commit the changes.
To update the patches, open common.py, update the GIT_REVISION variable, then call:
python generate_patch.pyThis will automatically update "patch" folder of this repository. Commit the modifications, push to a branch and create a pull request.
While you may use SlicerCore as-is, it is indended to be the base of trame-slicer.
Apache License, Version 2.0. See LICENSE file for details.