[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#38408] [PATCH v17 5/8] import: crate: Parameterized importing of de
From: |
Hartmut Goebel |
Subject: |
[bug#38408] [PATCH v17 5/8] import: crate: Parameterized importing of dev dependencies. |
Date: |
Mon, 16 Nov 2020 20:07:25 +0100 |
From: Martin Becze <mjbecze@riseup.net>
The recursive crate importer will now include development dependencies only
for the top level package, but not for any of the recursively imported
packages. Also #:skip-build will be false for the top-most package.
* guix/import/crate.scm (make-crate-sexp): Add the key BUILD?.
(crate->guix-package): Add the key INCLUDE-DEV-DEPS?.
(crate-recursive-import): Likewise.
* guix/scripts/import/crate.scm (guix-import-crate): Likewise.
* tests/crate.scm (cargo-recursive-import): Likewise.
---
guix/import/crate.scm | 25 ++++++++++++++++++-------
guix/scripts/import/crate.scm | 2 +-
tests/crate.scm | 3 +--
3 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index c830449555..9704b3087b 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -151,7 +151,7 @@ record or #f if it was not found."
`((arguments (,'quasiquote ,args))))))
(define* (make-crate-sexp #:key name version cargo-inputs
cargo-development-inputs
- home-page synopsis description license)
+ home-page synopsis description license build?)
"Return the `package' s-expression for a rust package with the given NAME,
VERSION, CARGO-INPUTS, CARGO-DEVELOPMENT-INPUTS, HOME-PAGE, SYNOPSIS,
DESCRIPTION,
and LICENSE."
@@ -177,7 +177,9 @@ and LICENSE."
(base32
,(bytevector->nix-base32-string (port-sha256
port))))))
(build-system cargo-build-system)
- ,@(maybe-arguments (append '(#:skip-build? #t)
+ ,@(maybe-arguments (append (if build?
+ '()
+ '(#:skip-build? #t))
(maybe-cargo-inputs cargo-inputs)
(maybe-cargo-development-inputs
cargo-development-inputs)))
@@ -202,12 +204,13 @@ and LICENSE."
'unknown-license!)))
(string-split string (string->char-set " /"))))
-(define* (crate->guix-package crate-name #:key version repo)
+(define* (crate->guix-package crate-name #:key version include-dev-deps? repo)
"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, convert it into a semver range and attempt to fetch
the latest version matching this semver range; otherwise fetch the latest
-version of CRATE-NAME."
+version of CRATE-NAME. If INCLUDE-DEV-DEPS is true then this will also
+look up the development dependencs for the given crate."
(define (semver-range-contains-string? range version)
(semver-range-contains? (string->semver-range range)
@@ -263,9 +266,12 @@ version of CRATE-NAME."
(let* ((dependencies (crate-version-dependencies version*))
(dep-crates dev-dep-crates (partition normal-dependency?
dependencies))
(cargo-inputs (sort-map-dependencies dep-crates))
- (cargo-development-inputs '()))
+ (cargo-development-inputs (if include-dev-deps?
+ (sort-map-dependencies
dev-dep-crates)
+ '())))
(values
- (make-crate-sexp #:name crate-name
+ (make-crate-sexp #:build? include-dev-deps?
+ #:name crate-name
#:version (crate-version-number version*)
#:cargo-inputs cargo-inputs
#:cargo-development-inputs cargo-development-inputs
@@ -279,7 +285,12 @@ version of CRATE-NAME."
(define* (crate-recursive-import crate-name #:key version)
(recursive-import crate-name
- #:repo->guix-package (memoize crate->guix-package)
+ #:repo->guix-package (lambda* params
+ ;; download development dependencies only for the top
level package
+ (let ((include-dev-deps? (equal? (car params)
crate-name))
+ (crate->guix-package* (memoize
crate->guix-package)))
+ (apply crate->guix-package*
+ (append params `(#:include-dev-deps?
,include-dev-deps?)))))
#:version version
#:guix-name crate-name->package-name))
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 33dae56561..9252c52dfa 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -96,7 +96,7 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(if (assoc-ref opts 'recursive)
(crate-recursive-import name #:version version)
- (let ((sexp (crate->guix-package name #:version version)))
+ (let ((sexp (crate->guix-package name #:version version
#:include-dev-deps? #t)))
(unless sexp
(leave (G_ "failed to download meta-data for package '~a'~%")
(if version
diff --git a/tests/crate.scm b/tests/crate.scm
index 4465e12767..b6cd577552 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -536,8 +536,7 @@
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
+ ('quasiquote (#:cargo-inputs
(("rust-intermediate-a"
('unquote 'rust-intermediate-a-1.0.42))
("rust-intermediate-b"
--
2.21.3
- [bug#38408] [PATCH v17 0/8] New take continued: Semantic version aware recursive, Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 1/8] guix: self: Add guile-semver as a depenedency., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 2/8] import: utils: 'recursive-import' accepts an optional version parameter., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 8/8] import: crate: Use existing package satisfying semver requirement., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 5/8] import: crate: Parameterized importing of dev dependencies.,
Hartmut Goebel <=
- [bug#38408] [PATCH v17 3/8] import: crate: Use guile-semver to resolve module versions., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 4/8] import: crate: Memorize crate->guix-package., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 6/8] import: utils: Trim patch version from names., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 7/8] import: crate: Trim version for names after left-most non-zero part., Hartmut Goebel, 2020/11/16
- [bug#38408] [PATCH v17 0/8] New take continued: Semantic version aware recursive, Martin Becze, 2020/11/17