From patchwork Mon Sep 18 18:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 54041 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F096627BBE2; Mon, 18 Sep 2023 19:08:51 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 73AF827BBED for ; Mon, 18 Sep 2023 19:08:48 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiIeG-00071b-7j; Mon, 18 Sep 2023 14:07:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiIdI-00059c-6X for guix-patches@gnu.org; Mon, 18 Sep 2023 14:06:06 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiIdH-00045G-Uu for guix-patches@gnu.org; Mon, 18 Sep 2023 14:06:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qiIdQ-0002WG-4x for guix-patches@gnu.org; Mon, 18 Sep 2023 14:06:12 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66088] [PATCH v2 05/23] DRAFT import: juliahub: Add support for native-inputs. Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 18 Sep 2023 18:06:11 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66088 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62202@debbugs.gnu.org Cc: 66088@debbugs.gnu.org, zimon.toutoune@gmail.com X-Debbugs-Original-Cc: Nicolas Graves via Guix-patches via , Simon Tournier Received: via spool by submit@debbugs.gnu.org id=B.16950603639479 (code B ref -1); Mon, 18 Sep 2023 18:06:11 +0000 Received: (at submit) by debbugs.gnu.org; 18 Sep 2023 18:06:03 +0000 Received: from localhost ([127.0.0.1]:54479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiIdF-0002SW-TH for submit@debbugs.gnu.org; Mon, 18 Sep 2023 14:06:02 -0400 Received: from lists.gnu.org ([2001:470:142::17]:58286) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiIbc-0002JD-VI for submit@debbugs.gnu.org; Mon, 18 Sep 2023 14:04:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiIb4-0002JT-0E for guix-patches@gnu.org; Mon, 18 Sep 2023 14:03:54 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiIb1-0003Ov-DT for guix-patches@gnu.org; Mon, 18 Sep 2023 14:03:45 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31ffc8ead75so316824f8f.0 for ; Mon, 18 Sep 2023 11:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695060222; x=1695665022; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pUwfyNhRnqWCM1lX3AZ3mporZaHjg2ab0aRjRiR2Z/4=; b=dDIyGhA7WDQqzLLragsvbGIZbwBe92X9Fmg9W9fjaZBagLzE0cr6+58567iqiGoaKO nbxwCF3mvRV0ME9mBtHmNDG31wBvlexWC/6m1bSh0XHyp6hNr9YYksYhkRnQ/7l8jGwX ZI+W64mkGruk4mU6/o8FTNExM5PMPdE/A2jZi5jr8YC3vJqj/OXSiGJrpFAiTlKo6+gE A4zNOtBuQbxqV9mP6Eb6DR1wa4Yyh+tcJ7OLRGfR7wYttmXK6qf+GZBoRXa3QlstIrKt V8ZlSZphpqYrtv7w8UDYKokjHGcXEhJ6z+nINhD/65qH7MwVqb17xa7GPT1aAGiFWhJw MfAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695060222; x=1695665022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pUwfyNhRnqWCM1lX3AZ3mporZaHjg2ab0aRjRiR2Z/4=; b=GbcclDOqKywp296amw8/iJtcTgSLsgSqgsznn7af1a1mAZYox9Ki4+X5qD1kRwHcz9 WCUZXHwKs5pm7wX/9YGW2jSLudFe/GEU3iOKLBw7aFOmAQCm3G3dDvVp0vUU+GzB4w9f P2UMkutyVOuZwkXMeqdBrVtiDrV7Vw8uAPYFH+ALQkhtoH/gx9pb5DjlIHqvxsgvO3sQ LjxV/gDOQFEq2iYQ6D++vJTEPmUnl12SroYf976gbR1BiTmg6BuR4dlqx/FkCD9TElqa Sg2zfLjo9ceN/2/ZJvnhh6kVINy764Im/jKKPLKxH6kqWm3z5x2xO7lpL+jXiSjFQvPq DCqw== X-Gm-Message-State: AOJu0YxoR6t88xh60d0Hd/DTnYzwQKXbyGT7dfoQzU4k7YLDFzl14/yl 2J1IQT97sI3n3cnkZ5U3os0= X-Google-Smtp-Source: AGHT+IHA9dJxZsHSpnwzDPRlIQKYNbbfGVWrNDVIvKxhl6OZNa4uC/tz0qT2H1n/Gnx6HbKueQcLdQ== X-Received: by 2002:a05:6000:1f9c:b0:320:b1e:7e6c with SMTP id bw28-20020a0560001f9c00b003200b1e7e6cmr4411813wrb.3.1695060221715; Mon, 18 Sep 2023 11:03:41 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id z2-20020adfd0c2000000b0030ada01ca78sm2210465wrh.10.2023.09.18.11.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:03:41 -0700 (PDT) From: Simon Tournier Date: Mon, 18 Sep 2023 20:03:12 +0200 Message-Id: <57feddb288135a1d5953340fcc5bfe9e3159e372.1695060058.git.zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Nicolas Graves via Guix-patches via Signed-off-by: Simon Tournier --- 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 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 - ;; (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 (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))