GNU bug report logs - #45288
[PATCH] import/cran: Add input style "specification".

Previous Next

Package: guix-patches;

Reported by: Ricardo Wurmus <rekado <at> elephly.net>

Date: Thu, 17 Dec 2020 09:44:02 UTC

Severity: normal

Tags: patch

Done: Ricardo Wurmus <rekado <at> elephly.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ricardo Wurmus <rekado <at> elephly.net>
Subject: bug#45288: closed ([PATCH] import/cran: Add input style
 "specification".)
Date: Tue, 22 Dec 2020 15:20:01 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#45288: [PATCH] import/cran: Add input style "specification".

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 45288 <at> debbugs.gnu.org.

-- 
45288: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=45288
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ricardo Wurmus <rekado <at> elephly.net>
To: 45288-done <at> debbugs.gnu.org
Subject: [PATCH] import/cran: Add input style "specification".
Date: Tue, 22 Dec 2020 16:19:12 +0100
Pushed with commit 5f5e3873d735d13824c172d779e6095d6947f340.

-- 
Ricardo

[Message part 3 (message/rfc822, inline)]
From: Ricardo Wurmus <rekado <at> elephly.net>
To: guix-patches <at> gnu.org
Cc: Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH] import/cran: Add input style "specification".
Date: Thu, 17 Dec 2020 10:42:45 +0100
* guix/import/cran.scm (%input-style): New parameter.
(format-inputs): Use it.
* guix/scripts/import/cran.scm (guix-import-cran): Set the %input-style
parameter.
 (%options): Add "--style" option.
* doc/guix.texi (Invoking guix import): Document it.
---
 doc/guix.texi                |  7 ++++++
 guix/import/cran.scm         | 13 +++++++++--
 guix/scripts/import/cran.scm | 45 ++++++++++++++++++++----------------
 3 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 392baf5910..74cd86be37 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -11009,6 +11009,13 @@ When @option{--recursive} is added, the importer will traverse the
 dependency graph of the given upstream package recursively and generate
 package expressions for all those packages that are not yet in Guix.
 
+When @option{--style=specification} is added, the importer will generate
+package definitions whose inputs are package specifications instead of
+references to package variables.  This is useful when generated package
+definitions are to be appended to existing user modules, as the list of
+used package modules need not be changed.  The default is
+@option{--style=variable}.
+
 When @option{--archive=bioconductor} is added, metadata is imported from
 @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
 packages for the analysis and comprehension of high-throughput
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index 9d38be7a1e..fd44d80915 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -51,7 +51,9 @@
   #:use-module (guix upstream)
   #:use-module (guix packages)
   #:use-module (gnu packages)
-  #:export (cran->guix-package
+  #:export (%input-style
+
+            cran->guix-package
             bioconductor->guix-package
             cran-recursive-import
             %cran-updater
@@ -74,6 +76,9 @@
 ;;;
 ;;; Code:
 
+(define %input-style
+  (make-parameter 'variable)) ; or 'specification
+
 (define string->license
   (match-lambda
    ("AGPL-3" 'agpl3+)
@@ -128,7 +133,11 @@
 (define (format-inputs names)
   "Generate a sorted list of package inputs from a list of package NAMES."
   (map (lambda (name)
-         (list name (list 'unquote (string->symbol name))))
+         (case (%input-style)
+           ((specification)
+            (list name (list 'unquote (list 'specification->package name))))
+           (else
+            (list name (list 'unquote (string->symbol name))))))
        (sort names string-ci<?)))
 
 (define* (maybe-inputs package-inputs #:optional (type 'inputs))
diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
index 20e82ae2ca..4767bc082d 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -67,6 +67,10 @@ Import and convert the CRAN package for PACKAGE-NAME.\n"))
                  (lambda (opt name arg result)
                    (alist-cons 'repo (string->symbol arg)
                                (alist-delete 'repo result))))
+         (option '(#\s "style") #t #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'style (string->symbol arg)
+                               (alist-delete 'style result))))
          (option '(#\r "recursive") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'recursive #t result)))
@@ -93,23 +97,24 @@ Import and convert the CRAN package for PACKAGE-NAME.\n"))
                              value)
                             (_ #f))
                            (reverse opts))))
-    (match args
-      ((package-name)
-       (if (assoc-ref opts 'recursive)
-           ;; Recursive import
-           (with-error-handling
-             (map package->definition
-                  (filter identity
-                          (cran-recursive-import package-name
-                                                 #:repo (or (assoc-ref opts 'repo) 'cran)))))
-           ;; Single import
-           (let ((sexp (cran->guix-package package-name
-                                           #:repo (or (assoc-ref opts 'repo) 'cran))))
-             (unless sexp
-               (leave (G_ "failed to download description for package '~a'~%")
-                      package-name))
-             sexp)))
-      (()
-       (leave (G_ "too few arguments~%")))
-      ((many ...)
-       (leave (G_ "too many arguments~%"))))))
+    (parameterize ((%input-style (assoc-ref opts 'style)))
+      (match args
+        ((package-name)
+         (if (assoc-ref opts 'recursive)
+             ;; Recursive import
+             (with-error-handling
+               (map package->definition
+                    (filter identity
+                            (cran-recursive-import package-name
+                                                   #:repo (or (assoc-ref opts 'repo) 'cran)))))
+             ;; Single import
+             (let ((sexp (cran->guix-package package-name
+                                             #:repo (or (assoc-ref opts 'repo) 'cran))))
+               (unless sexp
+                 (leave (G_ "failed to download description for package '~a'~%")
+                        package-name))
+               sexp)))
+        (()
+         (leave (G_ "too few arguments~%")))
+        ((many ...)
+         (leave (G_ "too many arguments~%")))))))
-- 
2.29.2





This bug report was last modified 4 years and 149 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.