otb: fix python support

* switch to an older swig version
* add a patch to find ITK missing headers

daspk04 d73ff0a7 43b32614

+49 -4
+17
pkgs/by-name/ot/otb/1-otb-swig-include-itk.diff
··· 1 + diff --git a/Modules/Core/Wrappers/SWIG/src/python/CMakeLists.txt b/Modules/Core/Wrappers/SWIG/src/python/CMakeLists.txt 2 + index 1a33064..d791805 100644 3 + --- a/Modules/Core/Wrappers/SWIG/src/python/CMakeLists.txt 4 + +++ b/Modules/Core/Wrappers/SWIG/src/python/CMakeLists.txt 5 + @@ -17,6 +17,12 @@ 6 + # See the License for the specific language governing permissions and 7 + # limitations under the License. 8 + # 9 + +# Add ITK 10 + +find_package(ITK REQUIRED) 11 + +include(${ITK_USE_FILE}) 12 + +include_directories(${ITK_INCLUDE_DIRS}) 13 + +message(STATUS "ITK FOUND: ${ITK_INCLUDE_DIRS}") 14 + + 15 + include_directories( ${Python_INCLUDE_DIRS} ) 16 + include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}) 17 + set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON )
+32 -4
pkgs/by-name/ot/otb/package.nix
··· 32 32 enableLearning ? true, 33 33 enableMiscellaneous ? true, 34 34 enableOpenMP ? false, 35 - enablePython ? false, 35 + enablePython ? true, 36 36 extraPythonPackages ? ps: with ps; [ ], 37 37 enableRemote ? true, 38 38 enableShark ? true, ··· 49 49 # ITK configs for OTB requires 5.3.0 and 50 50 # filter out gdcm, libminc from list of ITK deps as it's not needed for OTB 51 51 itkVersion = "5.3.0"; 52 + itkMajorMinorVersion = lib.versions.majorMinor itkVersion; 52 53 itkDepsToRemove = [ 53 54 "gdcm" 54 55 "libminc" 55 56 ]; 56 57 itkIsInDepsToRemove = dep: builtins.any (d: d == dep.name) itkDepsToRemove; 57 58 59 + # remove after https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2451 60 + otbSwig = swig.overrideAttrs (oldArgs: { 61 + version = "4.2.1"; 62 + src = fetchFromGitHub { 63 + owner = "swig"; 64 + repo = "swig"; 65 + tag = "v4.2.1"; 66 + hash = "sha256-VlUsiRZLScmbC7hZDzKqUr9481YXVwo0eXT/jy6Fda8="; 67 + }; 68 + }); 69 + 58 70 # override the ITK version with OTB version 59 71 # https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/blob/develop/SuperBuild/CMake/External_itk.cmake?ref_type=heads#L145 60 72 otb-itk = (itk.override { enableRtk = false; }).overrideAttrs (oldArgs: { ··· 77 89 hash = "sha256-dDyqYOzo91afR8W7k2N64X6l7t6Ws1C9iuRkWHUe0fg="; 78 90 }) 79 91 ]; 92 + 93 + # fix the CMake config files for ITK which contains double slashes 94 + postInstall = 95 + (oldArgs.postInstall or "") 96 + + '' 97 + sed -i 's|''${ITK_INSTALL_PREFIX}//nix/store|/nix/store|g' $out/lib/cmake/ITK-${itkMajorMinorVersion}/ITKConfig.cmake 98 + ''; 80 99 81 100 cmakeFlags = oldArgs.cmakeFlags or [ ] ++ [ 82 101 (lib.cmakeBool "ITK_USE_SYSTEM_EIGEN" true) ··· 205 224 url = "https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/merge_requests/1056/diffs.patch"; 206 225 hash = "sha256-Zj/wkx0vxn5vqj0hszn7NxoYW1yf63G3HPVKbSdZIOY="; 207 226 }) 227 + ./1-otb-swig-include-itk.diff 208 228 ]; 209 229 230 + postPatch = ( 231 + "substituteInPlace Modules/Core/Wrappers/SWIG/src/python/CMakeLists.txt --replace-fail '''$''{ITK_INCLUDE_DIRS}' ${otb-itk}/include/ITK-${itkMajorMinorVersion}" 232 + ); 233 + 210 234 nativeBuildInputs = [ 211 235 cmake 212 236 makeWrapper 213 - swig 214 237 which 215 238 ]; 216 239 ··· 246 269 otb-itk 247 270 otb-shark 248 271 perl 249 - swig 250 272 tinyxml 251 273 ] 252 274 ++ otb-itk.propagatedBuildInputs 253 - ++ optionals enablePython ([ python3 ] ++ pythonInputs) 275 + ++ optionals enablePython ( 276 + [ 277 + python3 278 + otbSwig 279 + ] 280 + ++ pythonInputs 281 + ) 254 282 ++ optionals enableShark [ otb-shark ]; 255 283 256 284 doInstallCheck = true;