guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/03: refresh: Discard PyPI updater when Guile-JSON is missing.


From: Ludovic Courtès
Subject: 01/03: refresh: Discard PyPI updater when Guile-JSON is missing.
Date: Sun, 08 Nov 2015 21:21:30 +0000

civodul pushed a commit to branch master
in repository guix.

commit b68d2dbf0850d52e393f902dd64371cde85515a8
Author: Ludovic Courtès <address@hidden>
Date:   Sun Nov 8 21:57:42 2015 +0100

    refresh: Discard PyPI updater when Guile-JSON is missing.
    
    Reported by Sleep_Walker and Mathieu Lirzin <address@hidden>.
    
    * guix/scripts/refresh.scm (maybe-updater, list-updaters): New macros.
      (%updaters): Use 'list-updaters' instead of 'list'.  Make
      %PYPI-UPDATER conditional.
---
 guix/scripts/refresh.scm |   40 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 3984a0b..8c2ca81 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -30,7 +30,6 @@
   #:use-module ((guix gnu-maintenance) #:select (%gnu-updater))
   #:use-module (guix import elpa)
   #:use-module (guix import cran)
-  #:use-module (guix import pypi)
   #:use-module (guix gnupg)
   #:use-module (gnu packages)
   #:use-module ((gnu packages commencement) #:select (%final-inputs))
@@ -149,12 +148,43 @@ specified with `--select'.\n"))
 ;;; Updates.
 ;;;
 
+(define-syntax maybe-updater
+  ;; Helper macro for 'list-udpaters'.
+  (lambda (s)
+    (syntax-case s (=>)
+      ((_ ((module => updater) rest ...) (result ...))
+       (let ((met? (false-if-exception
+                    (resolve-interface (syntax->datum #'module)))))
+         (if met?
+             #'(maybe-updater (rest ...)
+                              (result ... (@ module updater)))
+             #'(maybe-updater (rest ...) (result ...)))))
+      ((_ (updater rest ...) (result ...))
+       #'(maybe-updater (rest ...) (result ... updater)))
+      ((_ () result)
+       #'result))))
+
+(define-syntax-rule (list-updaters updaters ...)
+  "Expand to '(list UPDATERS ...)' but only the subset of UPDATERS that are
+either unconditional, or have their requirement met.
+
+A conditional updater has this form:
+
+  ((SOME MODULE) => UPDATER)
+
+meaning that UPDATER is added to the list if and only if (SOME MODULE) could
+be resolved at macro expansion time.
+
+This is a way to discard at macro expansion time updaters that depend on
+unavailable optional dependencies such as Guile-JSON."
+  (maybe-updater (updaters ...) (list)))
+
 (define %updaters
   ;; List of "updaters" used by default.  They are consulted in this order.
-  (list %gnu-updater
-        %elpa-updater
-        %cran-updater
-        %pypi-updater))
+  (list-updaters %gnu-updater
+                 %elpa-updater
+                 %cran-updater
+                 ((guix import pypi) => %pypi-updater)))
 
 (define (lookup-updater name)
   "Return the updater called NAME."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]