Subject: [PATCH] gnu: gajim: Update to 1.7.3.
From: Parnikkapore <[email-masked]>
To: [email-masked]
Date: Mon, 12 Jun 2023 22:50:41 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/packages/messaging.scm (python-nbxmpp): Update to 4.2.2.
  [arguments]: Specify "python -m unittest" as test method,
  [inputs]: Move python dependencies to propagated-inputs.
  [propagated-inputs]: Likewise.
* gnu/packages/messaging.scm (gajim): Update to 1.7.3.
  [arguments]: Switch to "python -m build".
  To use pyproject-build-system, support for backend-path is needed.
  [arguments]: Add metadata build and install phase.
  [arguments]: Switch to "python -m unittest" as test method,
  following upstream recommendation.
  [arguments]: Generate gdk-pixbuf cache and include result in wrapper.
  Allows Gajim to run in pure environments.
  [native-search-paths]: Update.
* gnu/packages/messaging.scm (gajim-omemo): Update to 2.9.0.
* gnu/packages/messaging.scm (gajim-openpgp): Update to 1.5.0.
---

Here's a resend of https://issues.guix.gnu.org/63494 which is rebased
on top of current master. https://issues.guix.gnu.org/63594 is already
included.

I have gotten Gajim 1.8 working in Guix (see https://codeberg.org/Parnikkapore/guix-ngapsh-unsigned/src/commit/cc3069a118995e98ff971d51d36689ea6ceef366/pnkp/guix/packages/messaging.scm);
however, it requires python-protobuf >=4.21.0, which is not yet
packaged to Guix standards.

Again, sorry for consolidating the changes (and for `guix style`-ing python-nbxmpp)!

 gnu/packages/messaging.scm | 127 +++++++++++++++++++++----------------
 1 file changed, 72 insertions(+), 55 deletions(-)

diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 00897ea451..58a3eaaf22 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -148,6 +148,7 @@ (define-module (gnu packages messaging)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system pyproject)
   #:use-module (guix build-system qt)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
@@ -1088,27 +1089,34 @@ (define-public znc
 (define-public python-nbxmpp
   (package
     (name "python-nbxmpp")
-    (version "3.1.0")
-    (source
-     (origin
-       (method url-fetch)
-       (uri
-        (pypi-uri "nbxmpp" version))
-       (sha256
-        (base32 "0c32090gr1fiy7hkn73dcj4ad9gfdpks8hivl1dl8bql01jsfdnj"))))
-    (build-system python-build-system)
-    (native-inputs
-     (list `(,glib "bin")))
-    (inputs
-     (list glib
-           glib-networking
-           libsoup-minimal-2
-           python-gssapi
-           python-idna
-           python-precis-i18n
-           python-pygobject))
+    (version "4.2.2")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "nbxmpp" version))
+              (sha256
+               (base32
+                "095nyy6vjildhrqigxk6vsh49in6mx17bvb3z5zpjmzhv9b8ix46"))))
+    (build-system pyproject-build-system)
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  ;; XXX: This probably should be an option for pyproject-build-system
+                  (replace 'check
+                    (lambda* (#:key tests? #:allow-other-keys)
+                      (when tests?
+                        (invoke "python" "-m" "unittest" "-v")))))))
+    (native-inputs (list `(,glib "bin")))
+    (inputs (list glib
+                  glib-networking
+                  libsoup-minimal))
+    (propagated-inputs (list
+      python-gssapi
+      python-idna
+      python-packaging
+      python-precis-i18n
+      python-pygobject))
     (synopsis "Non-blocking XMPP Module")
-    (description "Python-nbxmpp is a Python library that provides a way for
+    (description
+     "Python-nbxmpp is a Python library that provides a way for
 Python applications to use the XMPP network.  This library was initially a fork
 of xmpppy.")
     (home-page "https://dev.gajim.org/gajim/python-nbxmpp")
@@ -1117,7 +1125,7 @@ (define-public python-nbxmpp
 (define-public gajim
   (package
     (name "gajim")
-    (version "1.4.7")
+    (version "1.7.3")
     (source
      (origin
        (method url-fetch)
@@ -1126,7 +1134,7 @@ (define-public gajim
                        (version-major+minor version)
                        "/gajim-" version ".tar.gz"))
        (sha256
-        (base32 "1ww46qlxr14nq0ka8wsf8qpn5qfi5dvgyksfh9411crl7azhfj0s"))
+        (base32 "066kvkjw3qcdanr3nczy0wgcwihk9jc9zhzfr5bwlqvcyxcv7k5p"))
        (patches (search-patches "gajim-honour-GAJIM_PLUGIN_PATH.patch"))))
     (build-system python-build-system)
     (arguments
@@ -1139,13 +1147,27 @@ (define-public gajim
          #:prefix glib-or-gtk:)
         (guix build utils))
        #:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'disable-failing-tests
+       ,#~(modify-phases %standard-phases
+         (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file
+            (assoc-ref glib-or-gtk:%standard-phases
+                       'generate-gdk-pixbuf-loaders-cache-file))
+         (add-before 'build 'build-metadata
+          (lambda _
+            (invoke "./pep517build/build_metadata.py" "-o" "dist/metadata")))
+         ;; TODO: Change to pyproject-build-system once it supports
+         ;; in-tree build backends.
+         (replace 'build
            (lambda _
-             ;; XXX Gajim builds fine on some (my) machines but fails elsewhere:
-             ;; ModuleNotFoundError: No module named 'gajim.gui.emoji_data'
-             ;; https://dev.gajim.org/gajim/gajim/-/issues/11041
-             (delete-file "test/no_gui/test_styling.py")))
+             (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
+         (replace 'install
+            (lambda _
+              (apply invoke "pip" "--no-cache-dir" "--no-input"
+                     "install" "--no-deps" "--prefix" #$output
+                     (find-files "dist" "\\.whl$"))))
+         (add-after 'install 'install-metadata
+          (lambda _
+            (invoke "./pep517build/install_metadata.py" "dist/metadata"
+                    (string-append "--prefix=" #$output))))
          (replace 'check
            (lambda _
              ;; Tests require a running X server.
@@ -1153,35 +1175,30 @@ (define-public gajim
              (setenv "DISPLAY" ":1")
              ;; For missing '/etc/machine-id'.
              (setenv "DBUS_FATAL_WARNINGS" "0")
-             (invoke "dbus-launch" "python" "./setup.py" "test")))
-         ;; Loading gajim_remote require running session bus,
-         ;; which in-turn requires running elogind for XDG_RUNTIME_DIR;
-         ;; neither of which are possible inside build environment.
-         (delete 'sanity-check)
+             (invoke "dbus-launch" "python" "-m" "unittest" "discover" "-s" "test")))
          (add-after 'install 'glib-or-gtk-compile-schemas
            (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
          (add-after 'install 'glib-or-gtk-wrap
            (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
          (add-after 'install 'wrap-env
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out")))
-               (for-each
-                (lambda (name)
-                  (let ((file (string-append out "/bin/" name))
-                        (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH"))
-                        (gi-typelib-path (getenv "GI_TYPELIB_PATH")))
-                    (wrap-program file
-                      `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path))
-                      `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path)))))
-                '("gajim" "gajim-remote"))))))))
+           (lambda _
+             (for-each
+               (lambda (name)
+                 (let ((file (string-append #$output "/bin/" name))
+                       (gst-plugin-path (getenv "GST_PLUGIN_SYSTEM_PATH"))
+                       (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
+                       (pixbuf-module-file (getenv "GDK_PIXBUF_MODULE_FILE")))
+                   (wrap-program file
+                     `("GST_PLUGIN_SYSTEM_PATH" ":" prefix (,gst-plugin-path))
+                     `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
+                     `("GDK_PIXBUF_MODULE_FILE" = (,pixbuf-module-file)))))
+               '("gajim" "gajim-remote")))))))
     (native-search-paths
      (list
       (search-path-specification
        (variable "GAJIM_PLUGIN_PATH")
-       (separator #f)                   ;single entry
-       (files
-        (list
-         "share/gajim/plugins")))
+       (separator #f) ; single entry
+       (files (list "share/gajim/plugins")))
       ;; Gajim needs to use the propagated inputs of its plugins.
       (search-path-specification
        (variable "GUIX_PYTHONPATH")
@@ -1192,7 +1209,7 @@ (define-public gajim
           ;; FIXME: Cannot use this expression as it would
           ;; introduce a circular dependency at the top level.
           ;; (version-major+minor (package-version python))
-          "3.9"
+          "3.10"
           "/site-packages"))))))
     (native-inputs
      (list gettext-minimal
@@ -1200,6 +1217,7 @@ (define-public gajim
            gobject-introspection
            `(,gtk+ "bin")
            python-distutils-extra
+           python-pypa-build
            python-setuptools
            xorg-server-for-tests))
     (inputs
@@ -1235,8 +1253,7 @@ (define-public gajim
            python-pycairo
            python-pygobject
            python-pyopenssl))
-    (propagated-inputs
-     (list dconf))
+    (propagated-inputs (list dconf))
     (synopsis "Fully-featured XMPP client")
     (description "Gajim aims to be an easy to use and fully-featured XMPP chat
 client.  It is extensible via plugins, supports end-to-end encryption (OMEMO
@@ -1247,7 +1264,7 @@ (define-public gajim
 (define-public gajim-omemo
   (package
     (name "gajim-omemo")
-    (version "2.8.15")
+    (version "2.9.0")
     (source
      (origin
        (method url-fetch/zipbomb)
@@ -1256,7 +1273,7 @@ (define-public gajim-omemo
          "https://ftp.gajim.org/plugins/master/omemo/omemo_"
          version ".zip"))
        (sha256
-        (base32 "1hf148ywr8knk5y3y5xvvwgw74ld1pcfjkp78g514ikcnzfycfcn"))))
+        (base32 "0yy9r9fsrlgdywiln8bskhi8faj9hnz7b19jcap5nkhv8jn9cqq7"))))
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
@@ -1283,7 +1300,7 @@ (define-public gajim-omemo
 (define-public gajim-openpgp
   (package
     (name "gajim-openpgp")
-    (version "1.4.9")
+    (version "1.5.0")
     (source
      (origin
        (method url-fetch/zipbomb)
@@ -1292,7 +1309,7 @@ (define-public gajim-openpgp
          "https://ftp.gajim.org/plugins/master/openpgp/openpgp_"
          version ".zip"))
        (sha256
-        (base32 "1xwmf6ai1z7z9x6p1ysglxji73r7d27c0gzc8ykab29cjhjyv0dq"))))
+        (base32 "193pbh9iri7bkamvjwp236i8g5zxxiqgsv64kll5sy76vx4q73c4"))))
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))

base-commit: dffaf42e5eac3822bd6b44e9749fc8e5f48fb99c
-- 
2.34.1