guix-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] import: pypi: add updater


From: Ludovic Courtès
Subject: Re: [PATCH] import: pypi: add updater
Date: Fri, 06 Nov 2015 15:07:06 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Mathieu Lirzin <address@hidden> skribis:

> Cyril Roelandt <address@hidden> writes:
>
>> * guix/import/pypi.scm (guix-package->pypi-name,
>>   latest-release): New procedures.
>>   (pypi-updater): New variable.
>> * guix/scripts/refresh.scm (%updaters): Add %PYPI-UPDATER.
>> ---
>>  guix/import/pypi.scm     | 50 
>> +++++++++++++++++++++++++++++++++++++++++++++++-
>>  guix/scripts/refresh.scm |  4 +++-
>>  2 files changed, 52 insertions(+), 2 deletions(-)
>>
>
> IIUC the commit bab020d7ca50e4153cf24832d119389a37fa8f63 has made
> Guile-JSON non optional.

Yes, a mistake.

> What should we do about this?

Something like this should work:

diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 3984a0b..4e9d1c8 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,35 @@ specified with `--select'.\n"))
 ;;; Updates.
 ;;;
 
+(define-syntax maybe-updater
+  (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.
+
+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
+  (list-updaters %gnu-updater
                  %elpa-updater
                  %cran-updater
-        %pypi-updater))
+                 ((guix import pypi) => %pypi-updater)))
 
 (define (lookup-updater name)
   "Return the updater called NAME."
Could you test in a JSON-less environment and report back?

Alternately, we could declare Guile-JSON to be mandatory.

TIA,
Ludo’.

reply via email to

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