From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OH5UNmubsmCNPgEAgWs5BA (envelope-from ) for ; Sat, 29 May 2021 21:52:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id +HBvMWubsmC8HQAAbx9fmQ (envelope-from ) for ; Sat, 29 May 2021 19:52:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F1F641EBB2 for ; Sat, 29 May 2021 21:52:10 +0200 (CEST) Received: from localhost ([::1]:47510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ln50E-000626-2C for larch@yhetil.org; Sat, 29 May 2021 15:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln506-00061q-NL for guix-patches@gnu.org; Sat, 29 May 2021 15:52:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ln506-000726-GA for guix-patches@gnu.org; Sat, 29 May 2021 15:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ln506-0007t5-EA for guix-patches@gnu.org; Sat, 29 May 2021 15:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48697] [PATCH] import: Add CHICKEN egg importer. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 29 May 2021 19:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48697 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 48697@debbugs.gnu.org, raingloom Received: via spool by 48697-submit@debbugs.gnu.org id=B48697.162231790030273 (code B ref 48697); Sat, 29 May 2021 19:52:02 +0000 Received: (at 48697) by debbugs.gnu.org; 29 May 2021 19:51:40 +0000 Received: from localhost ([127.0.0.1]:57751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln4zj-0007sC-N0 for submit@debbugs.gnu.org; Sat, 29 May 2021 15:51:40 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:41308 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln4zg-0007rn-Da for 48697@debbugs.gnu.org; Sat, 29 May 2021 15:51:39 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1622317888; bh=j9+MSZ/FRWOcnRmS75j6dTONqeAWj9740RYD5f1fkYU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=kC0Xb9qbjtpfQm5OBy0935762sjV4/vnC7gUXgOms78oQTr9Gg8ne7BVW8Dy2JpAX fAA81df/h9+Nlfi6715BdRZITiO/68+3v/2c/qiBn8qP1U7vx4XwPJ1SlAoWOdwp1m C3ByS+M25IdAzQpPLcaGrVouFLph3NGfiSnLJQDk= In-Reply-To: <87zgwd7anf.fsf@gnu.org> References: <87zgwd7anf.fsf@gnu.org> Date: Sat, 29 May 2021 21:51:06 +0200 Message-ID: <87eedppbdh.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622317931; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=4Xy3JVof7CQmY+t5Mf7WZrQDT1vdvZieicA/B6qVHs4=; b=LIaEcTi0kQiLUWeJ18Zx5LtkktAlgIdbvLaQ3rvDiWdvoV/+BZP/+dCCmmrcXV6Qq0GBMy lnmsz5HT8LU/1fTpigh81288hoD3ut4ru6FLYM7WPbmUQcEyB4bBVPhNtGE67phoUfrnr4 zlK2P32UIjYupqOKrL+iD7nYsz8IPoZGGM1uksTmeYNzPKVnfYDKpwKuSFiAyH49tGlpoQ SAtl39CCSCnv9oJuSXNeQ4ZMb8tMI3nHADmjhghUoqJ82ypnFDJrqQc/2vRcBN2CvumEik 4cEi60pLmQiKq2K5kAqe97Lt5SulAiKpX22/F85wdt8ZN8JH0oMO4eUcumU9tg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622317931; a=rsa-sha256; cv=none; b=gQV1elPt2BlYY9SE0IBkFplcdPb7rqSFf6uHKxhosqJ1ctjkF2FUuvAgLI8hCIKoB7+QVq jCANk8ZCBpk4vhf8x44adD+8Qr9G4Ut7ExUo4eT9tXKnD9BUybTGSUv0ROL/n06PQflVmJ QOO3qTl/U0xMeialcllIkYLnd7IZrl56+KFW+r8/3HEvY9E1/39imppApl5PisakB9d6O9 3ap6e/P+XXcLt1atlls6An4Re9wc5AeNsqJmuVcFfATcXmhPfxMMojHX6KS7HlQ7FJrhH1 5ooFfKCxZiifvc2kXTGTCA0N+JiBR8boQh4Mzi/6+HRZFptgAhmXO/IXd8rvDQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=kC0Xb9qb; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -3.43 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=kC0Xb9qb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: F1F641EBB2 X-Spam-Score: -3.43 X-Migadu-Scanner: scn1.migadu.com X-TUID: m+4IJoJwOP9L --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, May 29 2021, Ludovic Court=C3=A8s wrote: > Hello! > > Xinglu Chen skribis: > >> * guix/import/egg.scm: New file. >> * guix/scripts/import/egg.scm: New file. >> * tests/egg.scm: New file. >> * Makefile.am (MODULES, SCM_TESTS): Register them. >> * guix/scripts/import.scm (importers): Add egg importer. >> * doc/guix.texi (Invoking guix import, Invoking guix refresh): Document = it. > > Woohoo, very nice! > >> This patch adds recursive importer for CHICKEN eggs, the generated >> packages aren=E2=80=99t entirely complete, though. It gets information = from The >> PACKAGE.egg, which is just a Scheme file that contains a list of lists >> that specify the metadata for an egg. However, it doesn=E2=80=99t speci= fy a >> description, so I have just set the =E2=80=98description=E2=80=99 field = to #f for now. >> The licensing policy for eggs is also a bit vague[1], there is no strict >> naming format for licenses, and a lot of eggs just specify =E2=80=98BSD= =E2=80=99 rather >> than =E2=80=98BSD-N-Clause=E2=80=99. > > On IRC, Mario Goulart of CHICKEN fame mentioned that they are working on > it, linking to this discussion: > > https://lists.nongnu.org/archive/html/chicken-hackers/2020-10/msg00003.= html That=E2=80=99s great to see! >> The PACKAGE.egg file can also specify system dependencies, but there is >> no consistent format for this, sometimes strings are used, other times >> symbols are used, and sometimes the version of the package is also >> included. The user will have to double check the names and make sure >> they are correct. I am also unsure about whether the system >> dependencies should be =E2=80=98propagated-inputs=E2=80=99 or just =E2= =80=98inputs=E2=80=99. > > Probably just =E2=80=98inputs=E2=80=99, no? Why would they need to be pr= opagated? For > Guile (and Python, etc.) they have to be propagated because you need > .scm and .go files to be in the search path; but with CHICKEN, I believe > you end up with .so files, so there=E2=80=99s probably no need for propag= ation? > Not sure actually. Ah, that makes sense, I am actually not that familiar with CHICKEN. :) >> + #:use-module (ice-9 string-fun) > > Uh, first time I see this one (!). Maybe add #:select to clarify why > it=E2=80=99s used for. It=E2=80=99s needed for the =E2=80=98string-replace-substring=E2=80=99 proc= edure. Here is the relevant part of the Guile manual (in case you were curios) The following additional functions are available in the module =E2=80=98(ice-9 string-fun)=E2=80=99. They can be used with: =20=20 (use-modules (ice-9 string-fun)) =20=20 -- Scheme Procedure: string-replace-substring str substring replacement Return a new string where every instance of SUBSTRING in string STR has been replaced by REPLACEMENT. For example: =20=20 (string-replace-substring "a ring of strings" "ring" "rut") =E2=87=92 "a rut of struts" >> +(define %eggs-home-page >> + (make-parameter "https://api.call-cc.org/5/doc")) > > On IRC, Mario suggested that a better value may be > "https://wiki.call-cc.org/egg/". Indeed, that looks like a better page. >> +(define (get-eggs-repository) >> + "Update or fetch the latest version of the eggs repository and return= the path >> +to the repository." >> + (let*-values (((url) "git://code.call-cc.org/eggs-5-latest") >> + ((directory commit _) >> + (update-cached-checkout url))) >> + directory)) > > I=E2=80=99d call it =E2=80=98eggs-repository=E2=80=99 (without =E2=80=98g= et-=E2=80=99). > > Also, I recommend using srfi-71 instead of srfi-11 in new code. Oh, I didn=E2=80=99t know about that, definitely looks nicer. >> +(define (find-latest-version name) >> + "Get the latest version of the egg NAME." >> + (let ((directory (scandir (egg-directory name)))) >> + (if directory >> + (last directory) >> + (begin >> + (format #t (G_ "Package not found in eggs repository: ~a~%") = name) >> + #f)))) > > This should be rendered with =E2=80=98warning=E2=80=99 from (guix diagnos= tics). > > Or maybe it should be raised as a =E2=80=98formatted-message=E2=80=99 exc= eption? Not sure if it should be an exception or not, if you run =E2=80=98guix impo= rt egg=E2=80=99 on a package that doesn=E2=80=99t exist, it will already throw an error =2D-8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix import egg lasdkfj Package not found in eggs repository: lasdkfj guix import: error: failed to download meta-data for package 'lasdkfj' =2D-8<---------------cut here---------------end--------------->8--- >> +(define (get-metadata port) >> + "Parse the egg metadata from PORT." >> + (let ((content (read port))) >> + (close-port port) >> + content)) >> + >> +(define (egg-metadata name) >> + "Return the package metadata file for the egg NAME." >> + (let ((version (find-latest-version name))) >> + (if version >> + (get-metadata (open-file >> + (string-append (egg-directory name) "/" >> + version "/" name ".egg") >> + "r")) >> + #f))) > > Rather: > > (call-with-input-file (string-append =E2=80=A6) > read) > > =E2=80=A6 and you can remove =E2=80=98get-metadata=E2=80=99. Good idea. >> + ;; letters in them. >> + ;; >> + ;; There will probably still be some weird edge cases. >> + (string-replace-substring (string-downcase name*) " " ""))) > > How about: > > (string-map (lambda (chr) > (case chr > ((#\space) #\-) > (else chr))) > (string-downcase name)) > > ? That would also work, and then we don=E2=80=99t have to import (ice-9 string-fun). :) >> + (define egg-native-inputs >> + (let* ((test-dependencies (assoc-ref egg-content >> + 'test-dependencies)) >> + (build-dependencies (assoc-ref egg-content >> + 'build-dependencies)) >> + (test+build-dependencies (safe-append >> + test-dependencies >> + build-dependencies))) >> + (if (list? test+build-dependencies) >> + (map egg-parse-dependency >> + test+build-dependencies) >> + '()))) > > Use =E2=80=98match=E2=80=99. Arrange so =E2=80=98test-dependencies=E2=80= =99 and =E2=80=98build-dependencies=E2=80=99 > are always lists so you don=E2=80=99t need =E2=80=98safe-append=E2=80=99. > > Last, could you add files that contain translatable strings to > =E2=80=98po/guix/POTFILES.in=E2=80=99? Sure! > Otherwise LGTM. Could you send an updated patch? > > Thank you! > > Ludo=E2=80=99. Thanks for the review! v2 will be coming. :) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmCymyoVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5AiIP/3ndFwzFHoWnmpYJrsOhml7/ctLu YDYwkGwNKr1xdEmipJWaDgFIgdnMZbri60C1q6eRC+LxXsUOXTKvZZOT7/2v57Ef neCZyLk4Q9GwAvHAH8LSNgqaeQuT/LahexeYjW1EG45xoP0f9UCleEnYhngOT8g2 CJQnaOIx36bAK9q80v6Jut1SkocaciYWGmfQ5g7rUITp7AVcTEVIZCRH13d2vi8M D55t25+vaRjs+dinEu13xWYz8gA1v7ddfkuElo/dJ867vlym68I6uDwynFPscVIh yazqBio+bOMs2dcBW/z/68rhAOQ/d9NFGw8bRrnFvFakPB6HCIq5/JFAdmWkGbET iPwXFr5HoJkANXqV9MjTkCHBOOMf/AdlHczApmbhqs/ujg329ipH9VV4CjoFVgD6 +6ASmtD8kGJFpyMIT/wfqrTCwW41sd22gioFVH2ae+r+QWz/BxIXgIuBqSJj2yjv aGRTuhZ4TaNAWFXDBB87tYwAhOH4wwxg+XGMjHn1nTY/v91npaZNJPc5HwhDVvvr i4QEUbOZG/EcaqWP9+gPNxPRho6G7PC87Y7nQW9K9ZMvdQVVyi2502DXEb9vqN07 vmvB5SJiOo3sU/dUzZ3dhwxdHMtZ1Q2N6ZqgNRgnsgoAQdDDNv6BIQ96KXm2tXpL urlKFwRDdDAHm6r1 =o9RB -----END PGP SIGNATURE----- --=-=-=--