GNU bug report logs - #66088
[PATCH v2 05/23] DRAFT import: juliahub: Add support for native-inputs.

Previous Next

Package: guix-patches;

Reported by: Simon Tournier <zimon.toutoune <at> gmail.com>

Date: Mon, 18 Sep 2023 18:06:11 UTC

Severity: normal

Tags: patch

Merged with 66075, 66076, 66077, 66078, 66079, 66080, 66081, 66082, 66083, 66084, 66085, 66086, 66087, 66089, 66090, 66091, 66092

Done: Simon Tournier <zimon.toutoune <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66088 in the body.
You can then email your comments to 66088 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#66088; Package guix-patches. (Mon, 18 Sep 2023 18:06:12 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon Tournier <zimon.toutoune <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 18 Sep 2023 18:06:12 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: 62202 <at> debbugs.gnu.org
Cc: Nicolas Graves via Guix-patches via <guix-patches <at> gnu.org>,
 Simon Tournier <zimon.toutoune <at> gmail.com>
Subject: [PATCH v2 05/23] DRAFT import: juliahub: Add support for
 native-inputs.
Date: Mon, 18 Sep 2023 20:03:12 +0200
From: Nicolas Graves via Guix-patches via <guix-patches <at> gnu.org>

Signed-off-by: Simon Tournier <zimon.toutoune <at> gmail.com>
---
 guix/import/juliahub.scm | 105 ++++++++++++++++++++++++---------------
 1 file changed, 64 insertions(+), 41 deletions(-)

diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm
index efe6abbb2481..4544dee98016 100644
--- a/guix/import/juliahub.scm
+++ b/guix/import/juliahub.scm
@@ -20,13 +20,14 @@ (define-module (guix import juliahub)
   #:use-module (ice-9 textual-ports)
   #:use-module (ice-9 regex)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 streams)
   #:use-module (ice-9 string-fun)
-  #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9)
+  #:use-module (srfi srfi-11)
   #:use-module (guix http-client)
   #:use-module (guix import utils)
   #:use-module (guix import json)
-  #:use-module (guix base16)
   #:use-module (guix base32)
   #:use-module (guix packages)
   #:use-module (guix upstream)
@@ -66,19 +67,42 @@ (define (json->juliahub-direct-dependencies vector)
                #f)))
        (vector->list vector))))
 
+(define (ini-list->extra-dependencies lst)
+  (match lst
+    (('(extras) ooo ...)
+     (extra-list->extra-dependencies ooo))
+    (((tag) ooo ...)
+     (ini-list->extra-dependencies ooo))
+    ((attribute '= value ooo ...)
+     (ini-list->extra-dependencies ooo))
+    ('()
+     '())))
+
+(define (extra-list->extra-dependencies lst)
+  (match lst
+    ((attribute '= value ooo ...)
+     `(,(symbol->string attribute) ,@(extra-list->extra-dependencies ooo)))
+    (((tag) ooo ...)
+     '())
+    ('()
+     '())))
+
+(define (parse-extra-dependencies directory)
+  (let* ((port (open-input-file (string-append directory "/Project.toml")))
+         (ini-list (stream->list (port->stream port read))))
+    (close-port port)
+    (ini-list->extra-dependencies ini-list)))
+
 ;; Julia package.
 (define-json-mapping <juliahub-package> make-juliahub-package juliahub-package?
   json->juliahub-package
   (homepage juliahub-package-homepage) ;string
   (readme juliahub-package-readme) ;string
-  ;; (slug juliahub-package-slug) ;string
   (version juliahub-package-version) ;string
   (description juliahub-package-description) ;string
-  (dependencies
-   juliahub-package-dependencies "deps"
+  (direct-dependencies
+   juliahub-package-direct-dependencies "deps"
    json->juliahub-direct-dependencies) ;list of <juliahub-dependency>
-   ;; (lambda (vector)
-     ;; (map json->juliahub-dependency (vector->list vector))))
   (url juliahub-package-url) ;string
   (uuid juliahub-package-uuid) ;string
   (license juliahub-package-license)) ;string
@@ -90,7 +114,6 @@ (define-json-mapping <juliahub-dependency>
   (name juliahub-dependency-name) ;string
   (uuid juliahub-dependency-uuid) ;string
   (versions juliahub-dependency-versions "versions" vector->list)) ;list of strings
-  ;; (slug juliahub-dependency-slug) ;string
 
 (define (julia-name->guix-name name)
   (string-append "julia-" (snake-case name)))
@@ -100,27 +123,25 @@ (define* (juliahub-fetch name #:key (version #f))
   (and=> (json-fetch (string-append (juliahub-url name) "pkg.json"))
          json->juliahub-package))
 
-(define (make-julia-sexp name version uri hash home-page synopsis description
-                         dependencies licenses)
+(define (make-julia-sexp name source home-page synopsis description
+                         direct-dependencies test-dependencies-names licenses)
   "Return the `package' s-expression for a Julia package with the given NAME,
-VERSION, URI, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES."
+VERSION, URI, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES,
+TEST-DEPENDENCIES-NAMES and LICENSES."
   `(package
      (name ,(julia-name->guix-name name))
      (version ,version)
-     (source (origin
-               (method url-fetch)
-               (uri ,uri)
-               (sha256
-                (base32
-                 "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"
-                 ;; ,(bytevector->nix-base32-string hash)
-                 ))))
+     (source ,source)
      (build-system julia-build-system)
-     ,@(if (null? dependencies)
+     ,@(if (null? direct-dependencies)
            '()
-           `((inputs
+           `((propagated-inputs
               (list ,@(map (compose julia-name->guix-name juliahub-dependency-name)
-                           dependencies)))))
+                           direct-dependencies)))))
+     ,@(if (null? test-dependencies-names)
+           '()
+           `((native-inputs
+              (list ,@(map julia-name->guix-name test-dependencies-names)))))
      (synopsis ,synopsis)
      (description ,description)
      (home-page ,home-page)
@@ -135,26 +156,28 @@ (define* (juliahub->guix-package package-name
 `package' s-expression corresponding to that package, or #f on failure.
 Optionally include a VERSION string to fetch a specific version juliahub."
   (let ((package (if version
-                      (juliahub-fetch package-name version)
-                      (juliahub-fetch package-name))))
+                     (juliahub-fetch package-name version)
+                     (juliahub-fetch package-name))))
     (if package
-        (let* ((dependencies-names
-                (map juliahub-dependency-name
-                     (juliahub-package-dependencies package)))
-               (licenses
-                (map spdx-string->license
-                     (list (juliahub-package-license package)))))
-          (values (make-julia-sexp
-                   package-name
-                   (juliahub-package-version package)
-                   (juliahub-package-url package)
-                   "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"
-                   (juliahub-package-homepage package)
-                   (juliahub-package-description package)
-                   (beautify-description (juliahub-package-readme package))
-                   (juliahub-package-dependencies package)
-                   licenses)
-                  dependencies-names))
+        (let-values (((source directory)
+                     (git->origin+dir url `(tag-or-commit . ,package-version))))
+          (let* ((dependencies-names
+                  (map juliahub-dependency-name
+                       (juliahub-package-direct-dependencies package)))
+                 (licenses
+                  (map spdx-string->license
+                       (list (juliahub-package-license package))))
+                 (test-dependencies-names (parse-extra-dependencies directory)))
+            (values (make-julia-sexp
+                     package-name
+                     source
+                     (juliahub-package-homepage package)
+                     (juliahub-package-description package)
+                     (beautify-description (juliahub-package-readme package))
+                     (juliahub-package-direct-dependencies package)
+                     test-dependencies-names
+                     licenses)
+                    (append dependencies-names test-dependencies))))
         (values #f '()))))
 
 (define* (import-release package #:key (version #f))
-- 
2.38.1





bug closed, send any further explanations to 66088 <at> debbugs.gnu.org and Simon Tournier <zimon.toutoune <at> gmail.com> Request was from Simon Tournier <zimon.toutoune <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 18 Sep 2023 21:01:03 GMT) Full text and rfc822 format available.

Merged 66075 66076 66077 66078 66079 66080 66081 66082 66083 66084 66085 66086 66087 66088 66089. Request was from Simon Tournier <zimon.toutoune <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 18 Sep 2023 21:01:18 GMT) Full text and rfc822 format available.

Merged 66075 66076 66077 66078 66079 66080 66081 66082 66083 66084 66085 66086 66087 66088 66089 66090 66091 66092. Request was from Simon Tournier <zimon.toutoune <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 18 Sep 2023 21:01:19 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 17 Oct 2023 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 206 days ago.

Previous Next


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