ITK icon indicating copy to clipboard operation
ITK copied to clipboard

Guix package definition; Configure fails.

Open ForceFaction opened this issue 2 years ago • 16 comments

Description

I'm trying to write a Guix package definition for ITK. It's important to neither use bundled software (if possible/feasible) nor download additional assets during the build. I found ITK_USE_SYSTEM_LIBRARIES and set it to ON.

Steps to Reproduce

[ This may not help you much, if you don't use guix :( Maybe the logs below are enough] Paste the following into a file <name>.scm and try to build with guix build -K -f <name>.scm:

(use-modules
 (gnu packages algebra)
 (gnu packages check)
 (gnu packages compression)
 (gnu packages image)
 (gnu packages llvm)
 (gnu packages maths)
 (gnu packages perl)
 (gnu packages python)
 (gnu packages xml)
 (guix build-system cmake)
 (guix git-download)
 ((guix licenses) #:prefix license:)
 (guix packages))

(define-public itk
  (package
    (name "itk")
    (version "5.3.0")
    (source (origin
	      (method git-fetch)
	      (uri (git-reference
		    (url "https://github.com/InsightSoftwareConsortium/ITK")
		    (commit (string-append "v" version))))
	      (file-name (git-file-name name version))
	      (sha256
	       (base32 "1bx98lzafj83fxylm0qnxkn05rdlrvfc672f0n843hgis2wk0gfh"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags
       (list "-DBUILD_EXAMPLES=OFF"
	     "-DITK_USE_SYSTEM_LIBRARIES=ON"
	     "-DITK_USE_KWSTYLE=OFF")))
    (native-inputs
     (list clang
	   cppcheck
	   eigen
	   googletest
	   perl
	   python))
    (inputs
     (list expat
	   hdf5
	   libjpeg-turbo
	   libpng
	   libtiff
	   zlib))
    (outputs (list "out" "debug"))
    (synopsis "ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions")
    (description "The Insight Toolkit (ITK) is an open-source, cross-platform toolkit for N-dimensional scientific image processing, segmentation, and registration.  Segmentation is the process of identifying and classifying data found in a digitally sampled representation.  Typically the sampled representation is an image acquired from such medical instrumentation as CT or MRI scanners.  Registration is the task of aligning or developing correspondences between data. For example, in the medical environment, a CT scan may be aligned with a MRI scan in order to combine the information contained in both.")
    (home-page "https://itk.org")
    (license license:asl2.0)))

itk

Expected behavior

I'd like the configure phase to succeed.

Actual behavior

full log

-- Found GTest: /gnu/store/mbzav28sik3zr3kbw1jyh4qk3zmkh6xn-googletest-1.11.0/lib/cmake/GTest/GTestConfig.cmake (found version "1.11.0")
-- Found HDF5: /gnu/store/imz1fhpcg603a4ny7k9yla72d6y302aw-hdf5-1.10.7/lib/libhdf5_cpp.so;/gnu/store/imz1fhpcg603a4ny7k9yla72d6y302aw-hdf5-1.10.7/lib/libhdf5.so;/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libpthread.so;/gnu/store/8qv5kb2fgm4c3bf70zcg9l6hkf3qzpw9-zlib-1.2.11/lib/libz.so;/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libdl.so;/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libm.so;/gnu/store/imz1fhpcg603a4ny7k9yla72d6y302aw-hdf5-1.10.7/lib/libhdf5.so;/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libpthread.so;/gnu/store/8qv5kb2fgm4c3bf70zcg9l6hkf3qzpw9-zlib-1.2.11/lib/libz.so;/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libdl.so;/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libm.so (found version "1.10.7") found components: CXX C HL
-- Looking for mkstemp
-- Looking for mkstemp - found
-- Looking for tmpnam
-- Looking for tmpnam - found
-- Looking for tempnam
-- Looking for tempnam - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for popen
-- Looking for popen - found
-- Looking for fork
-- Looking for fork - found
-- Looking for vfork
-- Looking for vfork - found
-- Looking for fdopen
-- Looking for fdopen - found
-- Looking for strdup
-- Looking for strdup - found
-- Looking for getpwnam
-- Looking for getpwnam - found
-- Looking for select
-- Looking for select - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for system
-- Looking for system - found
-- Looking for rint
-- Looking for rint - found
-- Looking for copysign
-- Looking for copysign - found
-- Looking for round
-- Looking for round - found
-- Looking for fabsf
-- Looking for fabsf - found
-- Looking for srand48
-- Looking for srand48 - found
-- Looking for drand48
-- Looking for drand48 - found
-- Looking for sleep
-- Looking for sleep - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for include file sys/dir.h
-- Looking for include file sys/dir.h - found
-- Looking for include file sys/ndir.h
-- Looking for include file sys/ndir.h - not found
-- Looking for include file sys/wait.h
-- Looking for include file sys/wait.h - found
-- Looking for include file values.h
-- Looking for include file values.h - found
-- Looking for include file dirent.h
-- Looking for include file dirent.h - found
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Looking for include file dlfcn.h
-- Looking for include file dlfcn.h - found
-- Looking for include file vfork.h
-- Looking for include file vfork.h - not found
-- Looking for include file pwd.h
-- Looking for include file pwd.h - found
-- Looking for include file sys/select.h
-- Looking for include file sys/select.h - found
-- Found Perl: /gnu/store/hy6abswwv4d89zp464fw52z65fkzr7h5-perl-5.34.0/bin/perl (found version "5.34.0")
-- Configuring done
CMake Error at CMake/ITKModuleTest.cmake:196 (add_executable):
  Target "ITKCommonGTestDriver" links to target "GTest::GTest" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  Modules/Core/Common/test/CMakeLists.txt:680 (CreateGoogleTestDriver)


CMake Error at CMake/ITKModuleTest.cmake:196 (add_executable):
  Target "ITKCommonGTestDriver" links to target "GTest::Main" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  Modules/Core/Common/test/CMakeLists.txt:680 (CreateGoogleTestDriver)


CMake Error at CMake/ITKModuleTest.cmake:196 (add_executable):
  Target "ITKConnectedComponentsGTestDriver" links to target "GTest::GTest"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  Modules/Segmentation/ConnectedComponents/test/CMakeLists.txt:88 (CreateGoogleTestDriver)


CMake Error at CMake/ITKModuleTest.cmake:196 (add_executable):
  Target "ITKConnectedComponentsGTestDriver" links to target "GTest::Main"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  Modules/Segmentation/ConnectedComponents/test/CMakeLists.txt:88 (CreateGoogleTestDriver)


-- Generating done

Reproducibility

Everytime.

Versions

v5.3.0

Environment

I'm running GNU Guix, specifically:

$ guix describe
Generation 168	Feb 01 2023 13:00:36	(current)
  guix 14323ed
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 14323edcc37d9efaae2491cf5f57ea0621412d7e
  nonguix c694cf9
    repository URL: https://gitlab.com/nonguix/nonguix
    branch: master
    commit: c694cf9211db3cc8673f0e73708d53b75d26518b

Additional Information

It's of course possible to disable tests with -DBUILD_TESTING=OFF, but i'd rather like to run the tests :smile:

ForceFaction avatar Feb 06 '23 13:02 ForceFaction

Thank you for contributing an issue! 🙏

Welcome to the ITK community! 🤗👋☀️

We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜 Also, please check existing open issues and consider discussion on the ITK Discourse. 📖

github-actions[bot] avatar Feb 06 '23 13:02 github-actions[bot]

Perhaps take a look at https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/ThirdParty/GoogleTest/CMakeLists.txt and https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/ThirdParty/GoogleTest/itk-module-init.cmake and see if you can diagnose the problem with finding GTest?

dzenanz avatar Feb 06 '23 14:02 dzenanz

Thanks for the pointers. It was my fault. Now GTest is found and it seems to try to use it.

It still fails, because the build tries to download external data, which isn't allowed in Guix (as every build runs inside an isolated container only containing what has been specified as inputs). I suppose this data is necessary for the tests though?

Which file defines all the necessary files and the corresponding URLs?

-- Fetching "https://insightsoftwareconsortium.github.io/ITKTestingData/MD5/8aa41348437f595b21e08eb46726002a"
-- Fetching "https://data.kitware.com:443/api/v1/file/hashsum/MD5/8aa41348437f595b21e08eb46726002a/download"
-- Fetching "https://itk.org/files/ExternalData/MD5/8aa41348437f595b21e08eb46726002a"
-- Fetching "http://127.0.0.1:8080/ipfs/8aa41348437f595b21e08eb46726002a"
-- Fetching "https://ipfs.io/ipfs/8aa41348437f595b21e08eb46726002a"
-- Fetching "https://gateway.pinata.cloud/ipfs/8aa41348437f595b21e08eb46726002a"
-- Fetching "https://cloudflare-ipfs.com/ipfs/8aa41348437f595b21e08eb46726002a"
-- Fetching "https://dweb.link/ipfs/8aa41348437f595b21e08eb46726002a"
-- Fetching "https://insightsoftwareconsortium.github.io/ITKTestingData/SHA512/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
-- Fetching "https://data.kitware.com:443/api/v1/file/hashsum/SHA512/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b/download"
-- Fetching "https://itk.org/files/ExternalData/SHA512/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
-- Fetching "http://127.0.0.1:8080/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
-- Fetching "https://ipfs.io/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
-- Fetching "https://gateway.pinata.cloud/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
-- Fetching "https://cloudflare-ipfs.com/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
-- Fetching "https://dweb.link/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b"
CMake Error at /tmp/guix-build-itk-5.3.0.drv-0/source/CMake/ExternalData.cmake:1171 (message):


  Object MD5=8aa41348437f595b21e08eb46726002a not found at:

    https://insightsoftwareconsortium.github.io/ITKTestingData/MD5/8aa41348437f595b21e08eb46726002a ("Couldn't resolve host name")
    https://data.kitware.com:443/api/v1/file/hashsum/MD5/8aa41348437f595b21e08eb46726002a/download ("Couldn't resolve host name")
    https://itk.org/files/ExternalData/MD5/8aa41348437f595b21e08eb46726002a ("Couldn't resolve host name")
    http://127.0.0.1:8080/ipfs/8aa41348437f595b21e08eb46726002a ("Couldn't connect to server")
    https://ipfs.io/ipfs/8aa41348437f595b21e08eb46726002a ("Couldn't resolve host name")
    https://gateway.pinata.cloud/ipfs/8aa41348437f595b21e08eb46726002a ("Couldn't resolve host name")
    https://cloudflare-ipfs.com/ipfs/8aa41348437f595b21e08eb46726002a ("Couldn't resolve host name")
    https://dweb.link/ipfs/8aa41348437f595b21e08eb46726002a ("Couldn't resolve host name")

  Object
  SHA512=7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b
  not found at:

    https://insightsoftwareconsortium.github.io/ITKTestingData/SHA512/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't resolve host name")
    https://data.kitware.com:443/api/v1/file/hashsum/SHA512/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b/download ("Couldn't resolve host name")
    https://itk.org/files/ExternalData/SHA512/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't resolve host name")
    http://127.0.0.1:8080/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't connect to server")
    https://ipfs.io/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't resolve host name")
    https://gateway.pinata.cloud/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't resolve host name")
    https://cloudflare-ipfs.com/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't resolve host name")
    https://dweb.link/ipfs/7978c22b34eea3afd202e0d29222272bb499b00e5444fccf60f929383eed7c15da1bc868db7f6d09e6dd30c4b9df477435a3bcc8c24fbd8bfcbdca8a4149711b ("Couldn't resolve host name")

ForceFaction avatar Feb 06 '23 15:02 ForceFaction

Probably this file from https://github.com/InsightSoftwareConsortium/ITK/releases/tag/v5.3.0.

dzenanz avatar Feb 06 '23 16:02 dzenanz

Possibly take a look at #1937 and #1157.

dzenanz avatar Feb 06 '23 16:02 dzenanz

Thank you for the hints and apologies for not reading the release notes properly; this could have saved you some time :sweat_smile:

ForceFaction avatar Feb 06 '23 16:02 ForceFaction

@ForceFaction thank you for packaging ITK! :pray:

thewtex avatar Feb 06 '23 20:02 thewtex

It now builds and the tests get executed. The only tests that do not pass are tiff related -- 2 of them segfault and 3 state that the libtiff i provided doesn't allow to create files as large as the test requested. I looked into the Modules/ThirdParty folder and i wonder if tif_fax3sm.c is the reason because this gets generated.

I haven't had the time to check the segfaults though.

ForceFaction avatar Feb 07 '23 12:02 ForceFaction

@ForceFaction those tests are know to be flaky. You may want to exclude them. The large TIFF ones have a BigIO CTest label for easy exclusion.

thewtex avatar Feb 08 '23 19:02 thewtex

I'm trying to package ANTs and need some specific tweaks to the guix image-processing/insight-toolkit package, namely the buld must include 3rd party repos (Modules/Remote) for ITKGenericLabelInterpolator and ITKAdaptiveDenoising and use 5.4rc which needs KWStyle (?).

The guix game channel has code demonstrating some nifty tricks: use (origin ...) within (native-inputs ..) and a build phase mod (add-after 'unpack (lambda )) to copy that input into the source directory of ITK -- so network-restricted cmake can find what would have been retrieved with ITKModuleRemote.cmake:itk_fetch_module / FetchContent / git at config time.

I'm still very new to cmake and guix packaging. I've likely made a bigger mess than needed. But it compiles with the headers ANTs needs! https://github.com/NPACore/hpc-env/blob/master/guix/itk.scm

(The linked issues above [#1937 and #1157] were super helpful)

WillForan avatar Oct 18 '23 13:10 WillForan

@ForceFaction @WillForan thank you for your work to package ITK in Guix!

Please review this PR that adds Guix installation instructions to our docs. https://github.com/InsightSoftwareConsortium/ITK/pull/4337

thewtex avatar Nov 19 '23 01:11 thewtex

official guix is a little behind and doesn't prepackage the remote modules. but having a link is still pretty useful!

WillForan avatar Nov 20 '23 02:11 WillForan