~ruther/guix-local

548206f941875c435d3fe867dccae5d8c5d81ec6 — Nicolas Graves 4 months ago e03ecde
gnu: python-imagecodecs: Update to 2025.8.2.

Warning: In phase 'create-configuration, I've disabled 3 modules that
fail compilation with gcc@14, although they should theorically
compile: apng, lzo, tiff.  IMO it's a bit out of the scope for a
already heavy patch to try and fix C compilation errors. I added a
FIXME comment though.

* gnu/packages/python-xyz.scm (python-imagecodecs): Update to 2025.8.2.
[source]<snippet>: Remove code unbundling 3rd party modules.  Almost
all of those are not bundled in the sense that they are extracted and
patched from upstream sources, and using those upstream sources
directly won't help.
[build-system]: Switch to pyproject-build-system.
[arguments]: Use gexps.
<#:tests?>: Enable them.
<#:test-flags>: Ignore flaky test.
<#:phases>: Re-factor phase 'create-configuration. Add phase
'fix-sanity-check and 'configure-tests.
[inputs]: Add lcms, libheif, lzfse, python-blosc2.
[propagated-inputs]: Add python-matplotlib, python-tifffile.
[native-inputs]: Add python-pytest, python-setuptools.
[synopsis]: Improve style.

Change-Id: I1c13eea510136891c667741f73fbf1d3f4231551
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
1 files changed, 63 insertions(+), 71 deletions(-)

M gnu/packages/python-xyz.scm
M gnu/packages/python-xyz.scm => gnu/packages/python-xyz.scm +63 -71
@@ 12551,84 12551,76 @@ metrics.")
(define-public python-imagecodecs
  (package
    (name "python-imagecodecs")
    (version "2021.3.31")
    (version "2025.8.2")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "imagecodecs" version))
        (sha256
          (base32
            "0q7pslb6wd56vbcq2mdxwsiha32mxjr7mgqqfbq5w42q601p9pi0"))
        (modules '((guix build utils)))
        (snippet
         '(begin
            ;; Unbundle 3rd party modules.
            (delete-file-recursively "3rdparty")
            ;; Delete pre-generated Cython files.
            (for-each delete-file (find-files "imagecodecs" "_.*\\.c$"))
            #t))))
    (build-system python-build-system)
     (origin
       (method url-fetch)
       (uri (pypi-uri "imagecodecs" version))
       (sha256
        (base32 "0v7yglk100fnk0m9m5bnfph2vm1jpnxzrzz2lwk06dqcr6m75wia"))
       (modules '((guix build utils)))
       (snippet #~(for-each delete-file
                            ;; Delete pre-generated Cython files.
                            (find-files "imagecodecs" "_.*\\.c$")))))
    (build-system pyproject-build-system)
    (arguments
     `(#:tests? #f ; Tests are disabled, because dependencies are missing.
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'create-configuration
           (lambda* (#:key inputs #:allow-other-keys)
             ;; By default everything is enabled. We can selectively disable
             ;; extensions (and thus dependencies) by deleting them from the
             ;; EXTENSIONS dictionary.  This is upstream’s preferred way.
             (call-with-output-file "imagecodecs_distributor_setup.py"
               (lambda (port)
                 (format port "\
     (list
      #:test-flags
      ;; Some of those tests are flaky.
      #~(list "-k" "not test_cms_identity_transforms")
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'create-configuration
            (lambda _
              ;; By default everything is enabled. We can selectively disable
              ;; extensions (and thus dependencies) by deleting them from the
              ;; EXTENSIONS dictionary.  This is upstream’s preferred way.
              (call-with-output-file "imagecodecs_distributor_setup.py"
                (lambda (port)
                  (format port "\
def customize_build(EXTENSIONS, OPTIONS):
    del EXTENSIONS['aec']
    del EXTENSIONS['avif']
    del EXTENSIONS['bitshuffle']
    del EXTENSIONS['deflate']
    del EXTENSIONS['jpeg2k']
    del EXTENSIONS['jpeg12']
    del EXTENSIONS['jpegls']
    del EXTENSIONS['jpegxl']
    del EXTENSIONS['jpegxr']
    del EXTENSIONS['lerc']
    del EXTENSIONS['ljpeg']
    del EXTENSIONS['lzf']
    del EXTENSIONS['zfp']
    del EXTENSIONS['zopfli']
    OPTIONS['cythonize']
")))))
         ;; XXX: The installed scripts import packages that depend on
         ;; this package; disable import check to avoid the cycle.
         (delete 'sanity-check))))
~{    del EXTENSIONS[~s]~%~}~%"
                          (list "apng" "lzo" "tiff" ; FIXME Wrong version?
                                ;; Those rely on unpackaged inputs.
                                "aec" "avif" "bitshuffle" "brunsli" "deflate"
                                "jetraw" "jpeg2k" "jpegls" "jpegxl" "jpegxr"
                                "jpegxs" "lerc" "ljpeg" "lzf" "lzham" "mozjpeg"
                                "pcodec" "sperr" "sz3" "szip" "ultrahdr" "zfp"
                                "zlibng" "zopfli"))))))
          (add-after 'unpack 'fix-sanity-check
            (lambda _
              ;; XXX: Don't exit twice. The generated script already does that.
              (substitute* "imagecodecs/__main__.py"
                (("sys\\.exit\\(main\\(\\)\\)")
                 ""))))
          (add-before 'check 'configure-tests
            (lambda _
              (setenv "HOME" (getcwd)))))))
    (inputs
      (list c-blosc
            giflib
            brotli
            libjpeg-turbo
            libpng
            libtiff
            libwebp
            lz4
            snappy
            xz
            zlib
            `(,zstd "lib")))
    (propagated-inputs
      ;; For the Python library.
      (list python-numpy))
     (list c-blosc
           giflib
           brotli
           lcms
           libheif
           libjpeg-turbo
           libpng
           libtiff
           libwebp
           lz4
           lzfse
           python-blosc2
           snappy
           xz
           zlib
           `(,zstd "lib")))
    (propagated-inputs
     (list python-numpy python-matplotlib python-tifffile))
    (native-inputs
      ;; For building.
      (list python-cython
            ;; For testing. Incomplete.
            ;("python-numcodecs" ,python-numcodecs)
            ;("python-zarr" ,python-zarr)
            ;("python-pytest" ,python-pytest)
            ))
     (list python-cython python-pytest python-setuptools))
    (home-page "https://www.lfd.uci.edu/~gohlke/")
    (synopsis
      "Image transformation, compression, and decompression codecs")
    (synopsis "Image transformation, compression, and decompression codecs")
    (description
      "Imagecodecs is a Python library that provides block-oriented, in-memory
     "Imagecodecs is a Python library that provides block-oriented, in-memory
buffer transformation, compression, and decompression functions for use in the
tifffile, czifile, and other scientific image input/output modules.")
    (license license:bsd-3)))