From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:38478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3hrT-0001yo-SP for guix-patches@gnu.org; Mon, 17 Feb 2020 09:59:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3hrS-0005of-FK for guix-patches@gnu.org; Mon, 17 Feb 2020 09:59:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33072) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3hrS-0005oZ-BV for guix-patches@gnu.org; Mon, 17 Feb 2020 09:59:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j3hrS-0004S5-BB for guix-patches@gnu.org; Mon, 17 Feb 2020 09:59:02 -0500 Subject: [bug#38408] [PATCH v9 2/8] guix: import: crate: Use semver to resovle module versions Resent-Message-ID: Date: Mon, 17 Feb 2020 16:57:59 +0200 From: Efraim Flashner Message-ID: <20200217145759.GM1968@E5400> References: <7dbe9a73fe56e1116d3207ef3cb9547a32b9a773.1580817140.git.mjbecze@riseup.net> <87y2t17047.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Thv7PGoFpDPJ7Oar" Content-Disposition: inline In-Reply-To: <87y2t17047.fsf@gnu.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 38408@debbugs.gnu.org, jsoo1@asu.edu, Martin Becze --Thv7PGoFpDPJ7Oar Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 17, 2020 at 03:35:20PM +0100, Ludovic Court=C3=A8s wrote: > Hi Martin & Efraim, >=20 > Thinking more about it, I=E2=80=99m not sure I fully understand why we ne= ed to > pay attention to semver here: >=20 > Martin Becze skribis: >=20 > > +(define* (crate->guix-package crate-name #:key version #:allow-other-k= eys) > > "Fetch the metadata for CRATE-NAME from crates.io, and return the > > `package' s-expression corresponding to that package, or #f on failure. > > When VERSION is specified, attempt to fetch that version; otherwise fe= tch the > > latest version of CRATE-NAME." > > =20 > > + (define (semver-range-contains-string? range version) > > + (semver-range-contains? (string->semver-range range) > > + (string->semver version))) > > + > > (define (normal-dependency? dependency) > > - (eq? (crate-dependency-kind dependency) 'normal)) > > + (or (eq? (crate-dependency-kind dependency) 'build) > > + (eq? (crate-dependency-kind dependency) 'normal))) > > =20 > > (define crate > > (lookup-crate crate-name)) > > @@ -204,21 +218,36 @@ latest version of CRATE-NAME." > > (or version > > (crate-latest-version crate))) > > =20 > > - (define version* > > + (define (find-version crate range) > > + "finds the a vesion of a crate that fulfils the semver " > > (find (lambda (version) > > - (string=3D? (crate-version-number version) > > - version-number)) > > + (semver-range-contains-string? > > + range > > + (crate-version-number version))) > > (crate-versions crate))) >=20 > The reason I wonder is that the HTTP API gives us rather precise > dependency requirements: >=20 > --8<---------------cut here---------------start------------->8--- > scheme@(guix import crate)> (crate-version-dependencies (car (crate-versi= ons (lookup-crate "blake2-rfc")))) > $8 =3D (#< id: "arrayvec" kind: normal requirement: "^0= =2E4.6"> #< id: "constant_time_eq" kind: normal requireme= nt: "^0.1.0"> #< id: "data-encoding" kind: dev requiremen= t: "^2.0.0"> #< id: "clippy" kind: normal requirement: "^= 0.0.41">) > --8<---------------cut here---------------end--------------->8--- >=20 > In the example above, the importer could =E2=80=9Cjust=E2=80=9D fetch ver= sion 0.4.6 of > arrayvec, version 0.1.0 of constant_time_eq, etc., no? >=20 > It=E2=80=99s an approximation because the caret (^) means more than just = this, > but hopefully it=E2=80=99s a good approximation. >=20 > Am I missing something? >=20 > Ludo=E2=80=99. Here we're looking at a minimum of 0.4.6 for arrayvec. According to here=C2=B9 we'd really want to import 0.4.12, which is the latest 0.4.x release. =C2=B9 https://crates.io/crates/arrayvec/versions --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --Thv7PGoFpDPJ7Oar Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl5KqfcACgkQQarn3Mo9 g1HUPw//V4YL5yf/EOoR7XB/s3SMPKSVQKIz/VbcqqvxZCPgVI0GQ0RShuVyTGmh 9gkG2FTNem9NAMte14rr1bYuVMdba25XKZWSiuvNK4p5CeWrjXVuJTSd8059UUWz mVRoxqOU1hAxqPvowfoO4SFjIBQQE1NTAstWd7uXrWk+SZgJJ4+RpBaaCKtXUz8C 8eqfCkt8XUJeoUwfafOi2bdGF9MHAkeZy3o8bSfgZ4QsTiIsmvUca07ERtxAszLX E4+gBb/sW4etW8imoEVRcahfa3HkSgPO2oFl4SL/DknoutbCwkVV3zOj9gZlo/21 YI8uXDkEzhqTpdpKb7MJEXQHmnyvAQxZt8wmBkNoOhQKrXsaaLNRQFd7zazJA2p0 F/GZdBTwmr4rTBQfDwyxns6zQmv65F1FbaatHVE8V/+ZnJXsevYMK0PJZXn/XrTm 6yyuHmc+9H+Rgi4XNAtSoVpjcCcgS9yv8yfEBErIwlPchm8fkVMokywpnYLjR21R cBR7AyqjUZdckHCDQl9TK7pBZ4TqmAf3HIT1mpfHoY01Dp1owncwZYeY+vjOHgqy jMKlEkRTJpY5WA+FQbxfSeJMlUrWWWFJaKONh5MhrdUqAPphNn3pOStKMob1kKlE 5ZSZFe6Qz43mjifSEVQ1IOfu1SOHoVI1geQi3KnFvvke+rLueEo= =zRpi -----END PGP SIGNATURE----- --Thv7PGoFpDPJ7Oar--