~ruther/guix-local

b5a3db7c478f20542b6f960e7d27b1e78f900545 — Jake Forster a year ago d212967
gnu: insight-toolkit: Fix Python module and add a test for it.

Insight Toolkit (ITK) Python module fails to import due to:
  AttributeError: module 'numpy' has no attribute 'bool'
Implement the fix from here:
<https://github.com/InsightSoftwareConsortium/ITK/pull/5402>

While ITK's test suite is disabled for good reason, we can test that the
Python module imports successfully.  Importing the Python module requires
NumPy.  It is added as a native-input instead of a propagated-input because
the "out" output is unrelated to Python.

* gnu/packages/image-processing.scm (insight-toolkit)[arguments]: Remove
'#tests? #f'.  Add #:imported-modules and #:modules.
<#:phases>: Delete 'check.  Add 'fix-numpy-bool and 'python-sanity-check.
[native-inputs]: Add python-numpy.
(insight-toolkit-legacy)[arguments]: Remove inherited phase
'python-sanity-check.
[native-inputs]: Remove inherited python-numpy.

Change-Id: Ia6d14c22cbea9cd9877da36f8f72e2e34ff8a8a6
Signed-off-by: Andreas Enge <andreas@enge.fr>
1 files changed, 24 insertions(+), 3 deletions(-)

M gnu/packages/image-processing.scm
M gnu/packages/image-processing.scm => gnu/packages/image-processing.scm +24 -3
@@ 1309,7 1309,11 @@ libraries designed for computer vision research and implementation.")
      (outputs '("out" "python"))
      (arguments
       (list
        #:tests? #f ;tests require network access and external data
        #:imported-modules (append %cmake-build-system-modules
                                   %pyproject-build-system-modules)
        #:modules '(((guix build pyproject-build-system) #:prefix py:)
                    (guix build cmake-build-system)
                    (guix build utils))
        #:configure-flags
        #~(list "-DITK_USE_GPU=ON"
                "-DITK_USE_SYSTEM_LIBRARIES=ON"


@@ 1377,7 1381,19 @@ libraries designed for computer vision research and implementation.")
                (delete-file
                  (string-append
                    "Modules/Remote/"
                    "MorphologicalContourInterpolation.remote.cmake")))))))
                    "MorphologicalContourInterpolation.remote.cmake"))))
            (add-after 'unpack 'fix-numpy-bool
              (lambda _
                ;; <https://github.com/InsightSoftwareConsortium/ITK/pull/5402>
                (substitute* (string-append "Wrapping/Generators/"
                                            "Python/itk/support/types.py")
                  (("np\\.bool") "np.bool_"))))
            (delete 'check)    ;tests require network access and external data
            (add-after 'install 'python-sanity-check
              (lambda* (#:key inputs outputs tests? #:allow-other-keys)
                (when tests?
                  (py:add-installed-pythonpath inputs outputs)
                  (invoke "python3" "-c" "import itk")))))))
      (inputs (list eigen
                    expat
                    fftw


@@ 1397,6 1413,7 @@ libraries designed for computer vision research and implementation.")
             gcc-13
             git-minimal
             pkg-config
             python-numpy               ;for phase 'python-sanity-check
             swig-next
             which
             (origin


@@ 1454,11 1471,15 @@ combine the information contained in both.")
                           (string-prefix? "-DITK_USE_PYTHON_LIMITED_API=" flag)
                           (string-prefix? "-DITK_USE_SYSTEM_CASTXML=" flag)
                           (string-prefix? "-DITK_USE_SYSTEM_SWIG=" flag))))
                   #$cf))))
                   #$cf))
         ((#:phases phases #~%standard-phases)
          #~(modify-phases #$phases
              (delete 'python-sanity-check)))))
     (inputs (modify-inputs (package-inputs insight-toolkit)
               (delete "python")))
     (native-inputs (modify-inputs (package-native-inputs insight-toolkit)
                      (delete "castxml")
                      (delete "python-numpy")
                      (delete "swig"))))))

(define-public itk-snap