[PATCH v2 05/23] DRAFT import: juliahub: Add support for native-inputs.

  • Done
  • quality assurance status badge
Details
One participant
  • Simon Tournier
Owner
unassigned
Submitted by
Simon Tournier
Severity
normal
Merged with

Debbugs page

Simon Tournier wrote 1 years ago
(address . 62202@debbugs.gnu.org)
57feddb288135a1d5953340fcc5bfe9e3159e372.1695060058.git.zimon.toutoune@gmail.com
From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>

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

Toggle diff (167 lines)
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
Simon Tournier wrote 1 years ago
control message for bug #66088
(address . control@debbugs.gnu.org)
864jjrnqsz.fsf@gmail.com
close 66088
quit
Simon Tournier wrote 1 years ago
control message for bug #66075
(address . control@debbugs.gnu.org)
86a5tjmc4o.fsf@gmail.com
merge 66075 66089 66088 66087 66086 66085 66084 66083 66082
quit
Simon Tournier wrote 1 years ago
(address . control@debbugs.gnu.org)
868r93mc3w.fsf@gmail.com
merge 66075 66092 66091 66090
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 66088@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 66088
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help