Skip to content

Commit

Permalink
Add a recipe for 3dSlicer (https://github.com/Slicer/Slicer)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
  • Loading branch information
martin-g committed Jan 10, 2025
1 parent 0bffd21 commit 9d50dfa
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 0 deletions.
26 changes: 26 additions & 0 deletions recipes/3dslicer/3dslicer.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git i/SuperBuild/External_CTK.cmake w/SuperBuild/External_CTK.cmake
index fb41007b04..f2e297de27 100644
--- i/SuperBuild/External_CTK.cmake
+++ w/SuperBuild/External_CTK.cmake
@@ -82,6 +82,7 @@ if(NOT DEFINED CTK_DIR AND NOT Slicer_USE_SYSTEM_${proj})
${${proj}_EP_ARGS}
GIT_REPOSITORY "${Slicer_${proj}_GIT_REPOSITORY}"
GIT_TAG "${Slicer_${proj}_GIT_TAG}"
+ PATCH_COMMAND patch -p1 < $ENV{RECIPE_DIR}/ctk-pythonqt-threads.patch
SOURCE_DIR ${EP_SOURCE_DIR}
BINARY_DIR ${EP_BINARY_DIR}
CMAKE_CACHE_ARGS
diff --git i/SuperBuild/External_SimpleITK.cmake w/SuperBuild/External_SimpleITK.cmake
index 694a241408..8fb53b6413 100644
--- i/SuperBuild/External_SimpleITK.cmake
+++ w/SuperBuild/External_SimpleITK.cmake
@@ -173,9 +173,6 @@ ExternalProject_Execute(${proj} \"install\" \"${PYTHON_EXECUTABLE}\" \"-m\" \"pi
-DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS:STRING=${ep_common_c_flags}
- -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
- -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED}
- -DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_VISIBILITY_PRESET:BOOL=default
-DBUILD_SHARED_LIBS:BOOL=${Slicer_USE_SimpleITK_SHARED}
-DBUILD_EXAMPLES:BOOL=OFF
48 changes: 48 additions & 0 deletions recipes/3dslicer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

set -xe

mkdir -p build && pushd build

cmake .. -GNinja \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DSlicer_RELEASE_TYPE="Stable" \
-DQt5_DIR=${PREFIX} \
-DSlicer_USE_SYSTEM_python=1 \
-DSlicer_USE_SYSTEM_python-numpy=1 \
-DSlicer_USE_SYSTEM_python-scipy=1 \
-DSlicer_USE_SYSTEM_python-pip=1 \
-DSlicer_USE_SYSTEM_python-setuptools=1 \
-DSlicer_USE_SYSTEM_python-ensurepip=1 \
-DSlicer_USE_SYSTEM_python-wheel=1 \
-DSlicer_USE_SYSTEM_LZMA=1 \
-DSlicer_USE_SYSTEM_zlib=1 \
-DSlicer_USE_SYSTEM_bzip2=1 \
-DSlicer_USE_SYSTEM_curl=1 \
-DSlicer_USE_SYSTEM_sqlite=1 \
-DSlicer_USE_SYSTEM_RapidJSON=1 \
-DSlicer_USE_SYSTEM_LibFFI=1 \
-DSlicer_USE_SYSTEM_DCMTK=1 \
-DSlicer_USE_SYSTEM_OpenSSL=1 \
-DSlicer_USE_SYSTEM_LibArchive=1 \
-DSlicer_USE_SimpleITK_SHARED="ON" \
-DSlicer_VTK_SMP_IMPLEMENTATION_TYPE="TBB" \
-DBUILD_TESTING="OFF" \
-DCMAKE_MESSAGE_LOG_LEVEL=ERROR

cmake --build . --target Slicer -- -j"${CPU_COUNT}" > build.log

# debug
ls -la

pushd Slicer-build
cmake --build . --target install

# debug
ls -la ${PREFIX}/bin

# -DSlicer_USE_SYSTEM_ITK=1 \
# -DSlicer_USE_SYSTEM_VTK=1 \
# -DSlicer_FORCED_WC_LAST_CHANGED_DATE="${last_revision_date}" \
# -DSlicer_FORCED_REVISION="${last_revision_hash}"
10 changes: 10 additions & 0 deletions recipes/3dslicer/ctk-pythonqt-threads.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- CTK/CMakeExternals/PythonQt.cmake 2022-07-13 18:42:03.304128760 -0500
+++ CTK/CMakeExternals/PythonQt.cmake.new 2022-07-13 18:41:59.961133207 -0500
@@ -109,6 +109,7 @@
PREFIX ${proj}${ep_suffix}
${location_args}
BUILD_COMMAND ""
+ PATCH_COMMAND patch -p1 < $ENV{RECIPE_DIR}/pythonqt-threads.patch
CMAKE_CACHE_ARGS
${ep_common_cache_args}
-DPythonQt_QT_VERSION:STRING=${CTK_QT_VERSION}
161 changes: 161 additions & 0 deletions recipes/3dslicer/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{% set name = "3dslicer" %}
{% set version = "5.6.2" %}
{% set sha256 = "821bd73f0c15b6d599961e5af4a86a32c8468c95927f9eab246ef879f8ff1a20" %}

package:
name: {{ name }}
version: {{ version }}

source:
url: https://github.com/Slicer/Slicer/archive/refs/tags/v{{ version }}.tar.gz
sha256: {{ sha256 }}
patches:
- 3dslicer.patch

build:
number: 0
skip: True # [osx or win]
script_env:
- QT_QPA_PLATFORM=offscreen

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ cdt('mesa-libgl-devel') }} # [linux]
- {{ cdt('mesa-dri-drivers') }} # [linux]
- {{ cdt('libselinux') }} # [linux]
- {{ cdt('libxdamage') }} # [linux]
- {{ cdt('libxxf86vm') }} # [linux]
- {{ cdt('libxext') }} # [linux]
- cmake
- ninja
- make
- git
- patch
host:
- pip
- python
- xorg-libxfixes # [linux]
- numpy
- scipy
- setuptools
- wheel
- packaging
- nose
- qt
- xorg-libxt
- xorg-libxext
- xorg-libxrender
- xorg-libxcomposite
- xorg-libxrandr
- xorg-libxtst
- curl
- openssl
- xz
- zlib
- bzip2
- curl
- sqlite
- rapidjson
- libffi
- dcmtk
- libxml2
- hdf5
- boost
- certifi
- idna
- requests
- urllib3
- charset-normalizer
- chardet
- pydicom
- six
- pillow
- dicomweb-client
- couchdb-python
- gitpython
- pyjwt
- deprecated
- wrapt
- cffi
- pynacl
- pygithub
- ffmpeg
- libpng
- libogg
- libtheora
- gl2ps
# - jpeg
- libtiff
- eigen
- expat
- libarchive
run:
- python
- numpy
- scipy
- wheel
- qt
- xorg-libxt
- xorg-libxext
- xorg-libxrender
- xorg-libxcomposite
- xorg-libxrandr
- xorg-libxtst
- curl
- openssl
- xz
- zlib
- bzip2
- curl
- sqlite
- rapidjson
- libffi
- dcmtk
- libxml2
- hdf5
- boost
- certifi
- idna
- requests
- urllib3
- charset-normalizer
- chardet
- pydicom
- six
- pillow
- dicomweb-client
- couchdb-python
- gitpython
- pyjwt
- wrapt
- cffi
- pynacl
- pygithub
- ffmpeg
- libpng
- libogg
- libtheora
- gl2ps
# - jpeg
- libtiff
- expat
- libarchive

test:
commands:
- Slicer --help

about:
home: "https://slicer.org"
dev_url: "https://github.com/Slicer/Slicer"
doc_url: "https://slicer.readthedocs.io/en/latest/"
summary: "Multi-platform, free open source software for visualization and image computing."
license: Custom OSS
license_family: BSD
license_file: License.txt

extra:
recipe-maintainers:
- martin-g
10 changes: 10 additions & 0 deletions recipes/3dslicer/pythonqt-threads.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- PythonQT/src/PythonQtPythonInclude.h 2022-07-13 18:08:39.364858312 -0500
+++ PythonQT/src/PythonQtPythonInclude.h.new 2022-07-13 18:23:21.880628826 -0500
@@ -35,7 +35,6 @@

// Undefine macros that Python.h defines to avoid redefinition warning.
#undef _POSIX_C_SOURCE
-#undef _POSIX_THREADS
#undef _XOPEN_SOURCE

// Undefine Qt keywords that conflict with Python headers

0 comments on commit 9d50dfa

Please sign in to comment.