* bug#26772: [PATCH 2/3] import: cran: Robustify cran-package?.
2017-05-04 10:06 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
@ 2017-05-04 10:06 ` Mathieu Othacehe
2017-05-12 22:11 ` Ludovic Courtès
2017-05-04 10:06 ` bug#26772: [PATCH 3/3] import: pypi: Robustify latest-release Mathieu Othacehe
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-05-04 10:06 UTC (permalink / raw)
To: 26772
* guix/import/cran.scm (package->upstream-name): Return #f if url
start and end index could not be determined.
(cran-package?): Check if the upstream-name can be extracted from
given package.
This fixes a failure of guix refresh on r-minimal because no
upsteam-name can be determined from ".../R-version.tar.gz" uri.
---
guix/import/cran.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index be34a75c8..20009e2af 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
;;; 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.
;;;
@@ -374,7 +375,8 @@ dependencies."
(start (string-rindex url #\/)))
;; The URL ends on
;; (string-append "/" name "_" version ".tar.gz")
- (substring url (+ start 1) end)))
+ (if (and start end)
+ (substring url (+ start 1) end) #f)))
(_ #f)))
(_ #f)))))
@@ -415,6 +417,9 @@ dependencies."
(define (cran-package? package)
"Return true if PACKAGE is an R package from CRAN."
(and (string-prefix? "r-" (package-name package))
+ ;; Check if the upstream name can be extracted from package uri.
+ (package->upstream-name package)
+ ;; Check if package uri(s) are prefixed by "mirror://cran".
(match (and=> (package-source package) origin-uri)
((? string? uri)
(string-prefix? "mirror://cran" uri))
--
2.12.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#26772: [PATCH 2/3] import: cran: Robustify cran-package?.
2017-05-04 10:06 ` bug#26772: [PATCH 2/3] import: cran: Robustify cran-package? Mathieu Othacehe
@ 2017-05-12 22:11 ` Ludovic Courtès
2017-05-13 10:44 ` Mathieu Othacehe
0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2017-05-12 22:11 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: 26772
Mathieu Othacehe <m.othacehe@gmail.com> skribis:
> * guix/import/cran.scm (package->upstream-name): Return #f if url
> start and end index could not be determined.
> (cran-package?): Check if the upstream-name can be extracted from
> given package.
[...]
> @@ -374,7 +375,8 @@ dependencies."
> (start (string-rindex url #\/)))
> ;; The URL ends on
> ;; (string-append "/" name "_" version ".tar.gz")
> - (substring url (+ start 1) end)))
> + (if (and start end)
> + (substring url (+ start 1) end) #f)))
This can be written as:
(and start end (substring url …))
> @@ -415,6 +417,9 @@ dependencies."
> (define (cran-package? package)
> "Return true if PACKAGE is an R package from CRAN."
> (and (string-prefix? "r-" (package-name package))
> + ;; Check if the upstream name can be extracted from package uri.
> + (package->upstream-name package)
> + ;; Check if package uri(s) are prefixed by "mirror://cran".
> (match (and=> (package-source package) origin-uri)
> ((? string? uri)
> (string-prefix? "mirror://cran" uri))
OK!
Do you think you could add this specific case (r-minimal) as a test case
for ‘cran-package?’ in tests/cran.scm? That would be awesome.
Otherwise LGTM, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#26772: [PATCH 2/3] import: cran: Robustify cran-package?.
2017-05-12 22:11 ` Ludovic Courtès
@ 2017-05-13 10:44 ` Mathieu Othacehe
2017-05-13 13:12 ` Ludovic Courtès
0 siblings, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-05-13 10:44 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 26772-done
Hi Ludo !
Thanks for the review.
> This can be written as:
>
> (and start end (substring url …))
Done.
>
>> @@ -415,6 +417,9 @@ dependencies."
>> (define (cran-package? package)
>> "Return true if PACKAGE is an R package from CRAN."
>> (and (string-prefix? "r-" (package-name package))
>> + ;; Check if the upstream name can be extracted from package uri.
>> + (package->upstream-name package)
>> + ;; Check if package uri(s) are prefixed by "mirror://cran".
>> (match (and=> (package-source package) origin-uri)
>> ((? string? uri)
>> (string-prefix? "mirror://cran" uri))
>
> OK!
>
> Do you think you could add this specific case (r-minimal) as a test case
> for ‘cran-package?’ in tests/cran.scm? That would be awesome.
>
> Otherwise LGTM, thanks!
Sure I pushed this patch with the change above and a new test in
tests/cran.scm :
--8<---------------cut here---------------start------------->8---
(test-equal "r-mininal is not a cran package"
#f
((@@ (guix import cran) cran-package?) r-minimal))
--8<---------------cut here---------------end--------------->8---
I also pushed the two other patches of the serie.
Mathieu
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#26772: [PATCH 2/3] import: cran: Robustify cran-package?.
2017-05-13 10:44 ` Mathieu Othacehe
@ 2017-05-13 13:12 ` Ludovic Courtès
0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2017-05-13 13:12 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: 26772-done
Mathieu Othacehe <m.othacehe@gmail.com> skribis:
>> Do you think you could add this specific case (r-minimal) as a test case
>> for ‘cran-package?’ in tests/cran.scm? That would be awesome.
>>
>> Otherwise LGTM, thanks!
>
> Sure I pushed this patch with the change above and a new test in
> tests/cran.scm :
>
> (test-equal "r-mininal is not a cran package"
> #f
> ((@@ (guix import cran) cran-package?) r-minimal))
>
> I also pushed the two other patches of the serie.
Perfect, thank you!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#26772: [PATCH 3/3] import: pypi: Robustify latest-release.
2017-05-04 10:06 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
2017-05-04 10:06 ` bug#26772: [PATCH 2/3] import: cran: Robustify cran-package? Mathieu Othacehe
@ 2017-05-04 10:06 ` Mathieu Othacehe
2017-05-12 22:11 ` Ludovic Courtès
2017-05-04 10:09 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
2017-05-12 22:07 ` Ludovic Courtès
3 siblings, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-05-04 10:06 UTC (permalink / raw)
To: 26772
* guix/import/pypi.scm (latest-release): Check if pypi-fetch has
failed. If so return #f, else construct the <upstream-source>.
---
guix/import/pypi.scm | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 4f9518f2e..9c72e7331 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2015 Cyril Roelandt <tipecaml@gmail.com>
;;; 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.
;;;
@@ -322,15 +323,17 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
(define (latest-release 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))
- (metadata (pypi-fetch pypi-name))
- (version (assoc-ref* metadata "info" "version"))
- (url (assoc-ref (latest-source-release metadata) "url")))
- (upstream-source
- (package (package-name package))
- (version version)
- (urls (list url))))))
+ (let* ((pypi-name (guix-package->pypi-name package))
+ (pypi-package (pypi-fetch pypi-name)))
+ (and pypi-package
+ (guard (c ((missing-source-error? c) #f))
+ (let* ((metadata pypi-package)
+ (version (assoc-ref* metadata "info" "version"))
+ (url (assoc-ref (latest-source-release metadata) "url")))
+ (upstream-source
+ (package (package-name package))
+ (version version)
+ (urls (list url))))))))
(define %pypi-updater
(upstream-updater
--
2.12.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri.
2017-05-04 10:06 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
2017-05-04 10:06 ` bug#26772: [PATCH 2/3] import: cran: Robustify cran-package? Mathieu Othacehe
2017-05-04 10:06 ` bug#26772: [PATCH 3/3] import: pypi: Robustify latest-release Mathieu Othacehe
@ 2017-05-04 10:09 ` Mathieu Othacehe
2017-05-12 22:07 ` Ludovic Courtès
3 siblings, 0 replies; 10+ messages in thread
From: Mathieu Othacehe @ 2017-05-04 10:09 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: 26772
Oops, wrong file for copyright, I would fix it when commiting.
> +++ b/gnu/packages/statistics.scm
> @@ -7,6 +7,7 @@
> ;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
> ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
> ;;; Copyright © 2016, 2017 Raoul Bonnal <ilpuccio.febo@gmail.com>
> +;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri.
2017-05-04 10:06 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
` (2 preceding siblings ...)
2017-05-04 10:09 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
@ 2017-05-12 22:07 ` Ludovic Courtès
3 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2017-05-12 22:07 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: 26772
Mathieu Othacehe <m.othacehe@gmail.com> skribis:
> * gnu/packages/python.scm (python-termcolor): Remove "python-" from
> pypi uri.
>
> This was causing guix refresh to fail on this package.
OK!
^ permalink raw reply [flat|nested] 10+ messages in thread