import: pypi: Robustify latest-release.

* guix/import/pypi.scm (latest-release): Check if pypi-fetch has
  failed. If so return #f, else construct the <upstream-source>.
This commit is contained in:
Mathieu Othacehe 2017-05-04 11:57:50 +02:00
parent db427602d8
commit 22fc581db3
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
1 changed files with 12 additions and 9 deletions

View File

@ -2,6 +2,7 @@
;;; Copyright © 2014 David Thompson <davet@gnu.org> ;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2015 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2015 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -322,15 +323,17 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
(define (latest-release package) (define (latest-release package)
"Return an <upstream-source> for the latest release of PACKAGE." "Return an <upstream-source> for the latest release of PACKAGE."
(guard (c ((missing-source-error? c) #f)) (let* ((pypi-name (guix-package->pypi-name package))
(let* ((pypi-name (guix-package->pypi-name package)) (pypi-package (pypi-fetch pypi-name)))
(metadata (pypi-fetch pypi-name)) (and pypi-package
(version (assoc-ref* metadata "info" "version")) (guard (c ((missing-source-error? c) #f))
(url (assoc-ref (latest-source-release metadata) "url"))) (let* ((metadata pypi-package)
(upstream-source (version (assoc-ref* metadata "info" "version"))
(package (package-name package)) (url (assoc-ref (latest-source-release metadata) "url")))
(version version) (upstream-source
(urls (list url)))))) (package (package-name package))
(version version)
(urls (list url))))))))
(define %pypi-updater (define %pypi-updater
(upstream-updater (upstream-updater