Subject: [PATCH python-team v4 05/52] gnu: python-watchgod: Rename package to python-watchfiles.

From: Nicolas Graves <[email-masked]>
Date: Thu, 20 Feb 2025 08:53:26 +0100

* gnu/packages/python-xyz.scm (python-watchgod): Define in terms of
'deprecated-package'.
[version]: Update to 1.0.4.
[build-system]: Switch to cargo-build-system.
[arguments]: Likewise.
[native-inputs]: Add maturin, python-dirty-equals,
python-pytest-timeout, python-wrapper. Remove python-pygments,
python-pytest-sygar, python-setuptools and python-wheel.
(python-watchfiles): New variable, formerly known as
"python-watchgod".
---
 gnu/packages/python-xyz.scm | 61 +++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 38612df7c5..252c13ee13 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -300,6 +300,7 @@ (define-module (gnu packages python-xyz)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg)
+  #:use-module (guix deprecation)
   #:use-module (guix packages)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system cmake)
@@ -32628,39 +32629,56 @@ (define-public python-watchdog
 but portable.")
     (license license:asl2.0)))
 
-(define-public python-watchgod
+(define-public python-watchfiles
   (package
-    (name "python-watchgod")
-    (version "0.8.1")
+    (name "python-watchfiles")
+    (version "1.0.4")
     (source
      (origin
        ;; There are no tests in the PyPI tarball.
        (method git-fetch)
        (uri (git-reference
-             (url "https://github.com/samuelcolvin/watchgod")
+             (url "https://github.com/samuelcolvin/watchfiles")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0zm9xd2qf3d74l67yv8j3zhhhvi0vp25vhkg46l9d7flh9m04qrp"))))
-    (build-system pyproject-build-system)
+        (base32 "1kaxq0drjwlvcsg4in25w1bhjjgm1zlz06rr2macyi6s5x96g46h"))))
+    (build-system cargo-build-system)
     (arguments
-     (list #:test-flags '(list "-o" "asyncio_mode=auto"
-                               ;; PytestUnraisableExceptionWarning
-                               "-k" "not test_watch_log and not test_awatch")
-       #:phases #~(modify-phases %standard-phases
-                  (delete 'sanity-check))))
+     (list
+      #:install-source? #f
+      #:imported-modules `(,@%cargo-build-system-modules
+                           ,@%pyproject-build-system-modules)
+      #:modules '((guix build cargo-build-system)
+                  ((guix build pyproject-build-system) #:prefix py:)
+                  (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'build
+            (assoc-ref py:%standard-phases 'build))
+          (add-after 'build 'install-rust-library
+            (lambda _
+              (copy-file "target/release/lib_rust_notify.so"
+                         "watchfiles/_rust_notify.so")))
+          (replace 'check
+            (lambda* (#:key tests? test-flags #:allow-other-keys)
+              (if tests?
+                  ;; Missing file in source.
+                  (invoke "pytest" "-vv" "-k" "not test_docs_examples")
+                  (format #t "test suite not run~%"))))
+          (replace 'install
+            (assoc-ref py:%standard-phases 'install)))
+      #:cargo-inputs
+      (list rust-crossbeam-channel-0.5 rust-notify-7 rust-pyo3-0.23)))
     (native-inputs
-     (list python-anyio
-           python-coverage
-           python-pygments
+     (list maturin
+           python-anyio
+           python-dirty-equals
            python-pytest
-           python-pytest-asyncio
-           python-pytest-cov
            python-pytest-mock
-           python-pytest-sugar
-           python-setuptools
-           python-wheel))
-    (home-page "https://github.com/samuelcolvin/watchgod")
+           python-pytest-timeout
+           python-wrapper))
+    (home-page "https://github.com/samuelcolvin/watchfiles")
     (synopsis "Simple, modern file watching and code reload in Python")
     (description
      "Simple, modern file watching and code reload in Python inspired by
@@ -32668,6 +32686,9 @@ (define-public python-watchgod
 operating systems and an elegant approach to concurrency using threading.")
     (license license:expat)))
 
+(define-deprecated/alias python-watchgod python-watchfiles)
+(export python-watchgod)
+
 (define-public python-wget
   (package
     (name "python-wget")
-- 
2.48.1

-- 
Best regards,
Nicolas Graves