diff options
| author | Jake Forster <jakecameron.forster@gmail.com> | 2025-07-29 22:09:58 +0930 |
|---|---|---|
| committer | Andreas Enge <andreas@enge.fr> | 2025-08-11 18:57:23 +0200 |
| commit | b5a3db7c478f20542b6f960e7d27b1e78f900545 (patch) | |
| tree | 5b64ed3d898b07258944113d99b0c788c6313f20 /gnu/packages | |
| parent | d2129679340e4d735af518b71ea9b539a8b61a74 (diff) | |
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>
Diffstat (limited to 'gnu/packages')
| -rw-r--r-- | gnu/packages/image-processing.scm | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/gnu/packages/image-processing.scm b/gnu/packages/image-processing.scm index ab30dfa31d9..0f5cf2a3026 100644 --- a/gnu/packages/image-processing.scm +++ b/gnu/packages/image-processing.scm @@ -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 |
