mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-27 04:59:27 -05:00
import: crate: Memorize crate->guix-package.
This adds memorization to procedures that involve network lookups. 'lookup-crate*' is used on every dependency of a package to get its version list. It is also used to lookup a package's metadata. 'crate-recursive-import' is also memorized since creating the same package twice will trigger a lookup on its dependencies. * guix/import/crate.scm (lookup-crate*): New procedure. (crate->guix-package): Memorize package metadata lookups. (crate-recursive-import): Memorize package creation.
This commit is contained in:
parent
269c1db41b
commit
d9feb23e10
1 changed files with 6 additions and 3 deletions
|
@ -27,6 +27,7 @@ (define-module (guix import crate)
|
|||
#:use-module (guix import json)
|
||||
#:use-module (guix import utils)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (guix memoization)
|
||||
#:use-module (guix monads)
|
||||
#:use-module (guix packages)
|
||||
#:use-module (guix upstream)
|
||||
|
@ -110,6 +111,8 @@ (define (lookup-crate name)
|
|||
(json->crate `(,@alist
|
||||
("actual_versions" . ,versions))))))))
|
||||
|
||||
(define lookup-crate* (memoize lookup-crate))
|
||||
|
||||
(define (crate-version-dependencies version)
|
||||
"Return the list of <crate-dependency> records of VERSION, a
|
||||
<crate-version>."
|
||||
|
@ -215,7 +218,7 @@ (define (normal-dependency? dependency)
|
|||
(eq? (crate-dependency-kind dependency) 'normal)))
|
||||
|
||||
(define crate
|
||||
(lookup-crate crate-name))
|
||||
(lookup-crate* crate-name))
|
||||
|
||||
(define version-number
|
||||
(and crate
|
||||
|
@ -247,7 +250,7 @@ (define version*
|
|||
(define (sort-map-dependencies deps)
|
||||
(sort (map (lambda (dep)
|
||||
(let* ((name (crate-dependency-id dep))
|
||||
(crate (lookup-crate name))
|
||||
(crate (lookup-crate* name))
|
||||
(req (crate-dependency-requirement dep))
|
||||
(ver (find-crate-version crate req)))
|
||||
(list name
|
||||
|
@ -276,7 +279,7 @@ (define (sort-map-dependencies deps)
|
|||
|
||||
(define* (crate-recursive-import crate-name #:key version)
|
||||
(recursive-import crate-name
|
||||
#:repo->guix-package crate->guix-package
|
||||
#:repo->guix-package (memoize crate->guix-package)
|
||||
#:version version
|
||||
#:guix-name crate-name->package-name))
|
||||
|
||||
|
|
Loading…
Reference in a new issue