diff mbox series

[bug#55060,v4,6/8] gnu: Add python-pyvips.

Message ID 20220502211624.689372-7-paul@apatience.com
State Accepted
Headers show
Series gnu: Add python-pyvista. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Paul A. Patience May 2, 2022, 9:17 p.m. UTC
* gnu/packages/python-xyz.scm (python-pyvips): New variable.
---
 gnu/packages/python-xyz.scm | 60 +++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

--
2.36.0
diff mbox series

Patch

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 84f8b991e5..c70379a056 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -172,6 +172,7 @@  (define-module (gnu packages python-xyz)
   #:use-module (gnu packages haskell-xyz)
   #:use-module (gnu packages icu4c)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages image-processing)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages jupyter)
   #:use-module (gnu packages kerberos)
@@ -7582,6 +7583,65 @@  (define-public python-imageio
 data, and scientific formats.")
     (license license:bsd-2)))

+(define-public python-pyvips
+  (package
+    (name "python-pyvips")
+    (version "2.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pyvips" version))
+       (sha256
+        (base32 "0lq71iiic4pc8qhxr60gi141w25pjnn4vsh05d5l0fjkgjsv137b"))))
+    (build-system python-build-system)
+    (arguments
+     (list #:phases
+           #~(modify-phases %standard-phases
+               ;; Maybe switch to API mode (i.e., build the C extension)?
+               ;; It is advertised as faster to start up and run.
+               ;; However, even with ‘pkg-config’ and ‘python-pkgconfig’ in
+               ;; ‘native-inputs’, the API mode build fails with:
+               ;;
+               ;;   Falling back to ABI mode. Details: unable to find pkg-config package "vips"
+               ;;
+               ;; The build doesn't actually fail without the below
+               ;; substitution, it's just slower because ‘setup.py’ tries
+               ;; (unsuccessfully) to download the Python ‘pkgconfig’ module.
+               (add-after 'unpack 'fix-build
+                 (lambda _
+                   (substitute* "setup.py"
+                     (("^( +setup_)API\\(\\)\n" _ prefix)
+                      (string-append prefix "ABI()\n")))))
+               (add-after 'unpack 'fix-paths
+                 (lambda _
+                   (substitute* "pyvips/__init__.py"
+                     (("^( +_vips_libname) = '(libvips.so.42)'"
+                       _ var libname)
+                      (format #f "~a = '~a/lib/~a'"
+                              var #$(this-package-input "vips") libname))
+                     (("^( +_gobject_libname) = '(libgobject-2.0.so.0)'"
+                       _ var libname)
+                      (format #f "~a = '~a/lib/~a'"
+                              var #$(this-package-input "glib") libname)))))
+               (replace 'check
+                 (lambda* (#:key tests? #:allow-other-keys)
+                   (when tests?
+                     (invoke "python" "setup.py" "test")))))))
+    (native-inputs
+     (list python-pyperf
+           python-pytest
+           python-pytest-flake8
+           python-pytest-runner))
+    (inputs
+     (list glib vips))
+    (propagated-inputs
+     (list python-cffi))
+    (home-page "https://github.com/libvips/pyvips")
+    (synopsis "Python bindings for VIPS")
+    (description "The @code{pyvips} package provides Python bindings for VIPS,
+a multithreaded image-processing system with low memory needs.")
+    (license license:expat)))
+
 (define-public python-pycparser
   (package
     (name "python-pycparser")