GNU bug report logs - #62202
[PATCH 0/21] Juliahub import script.

Previous Next

Package: guix-patches;

Reported by: Nicolas Graves <ngraves <at> ngraves.fr>

Date: Wed, 15 Mar 2023 12:49:01 UTC

Severity: normal

Tags: moreinfo, patch

Full log


View this message in rfc822 format

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: 62202 <at> debbugs.gnu.org
Cc: zimon.toutoune <at> gmail.com
Subject: [bug#62202] [PATCH v2 15/23] DRAFT import: juliahub: Add support for versions for juliahub-fetch.
Date: Mon, 18 Sep 2023 20:03:22 +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 | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm
index b646f9329562..6ce0487dba38 100644
--- a/guix/import/juliahub.scm
+++ b/guix/import/juliahub.scm
@@ -122,7 +122,7 @@ (define %julia-stdlibs
         "Pkg"
         "LazyArtifacts"))
 
-(define (juliahub-uri name)
+(define (juliahub-redirect-uri name)
   (let* ((url (string-append "https://docs.juliahub.com/" name "/"))
          (port (http-fetch url #:text? #t))
          (_ (get-line port))
@@ -134,11 +134,11 @@ (define (juliahub-uri name)
 
 (define (juliahub-url name)
   (let* ((url (string-append "https://docs.juliahub.com/" name "/"))
-         (uri (juliahub-uri name)))
+         (uri (juliahub-redirect-uri name)))
     (string-append url uri "/")))
 
-(define (juliahub-slug-version name)
-  (let* ((uri (juliahub-uri name))
+(define (juliahub-slug+version name)
+  (let* ((uri (juliahub-redirect-uri name))
          (slug (string-take uri 5))
          (latest-version (string-drop uri 6)))
     `(,slug ,latest-version)))
@@ -203,8 +203,12 @@ (define (julia-name->guix-name name)
 
 (define* (juliahub-fetch name #:key (version #f))
   "Return a <juliahub-package> record for package NAME, or #f on failure."
-  (and=> (json-fetch (string-append (juliahub-url name) "pkg.json"))
-         json->juliahub-package))
+  (let ((url (if version
+                 (string-append "https://docs.juliahub.com/" name "/"
+                                (car (juliahub-slug+version name)) "/"
+                                version "/pkg.json")
+                 (string-append (juliahub-url name) "pkg.json"))))
+    (and=> (json-fetch url) json->juliahub-package)))
 
 (define (make-julia-sexp name source home-page synopsis description
                          direct-dependencies test-dependencies-names licenses)
@@ -242,9 +246,9 @@ (define* (juliahub->guix-package package-name
          (subdir (assoc-ref package-toml 'subdir))
          (tag (latest-git-tag (assoc-ref package-toml 'repo)))
          (package (if version
-                      (juliahub-fetch package-name version)
+                      (juliahub-fetch package-name #:version version)
                       (if tag
-                          (juliahub-fetch package-name tag)
+                          (juliahub-fetch package-name #:version tag)
                           (juliahub-fetch package-name)))))
     (if package
         (let-values (((source directory)
-- 
2.38.1





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

Previous Next


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