Subject: bug#29847: closed (Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 02 Apr 2018 16:17:02 +0000

Your bug report

#29847: [PATCH] import: pypi: Stay in the REPL if fail to get a source

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
29847: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29847
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
From: [email-masked] (Ludovic Courtès)
To: Oleg Pykhalov <[email-masked]>
Cc: [email-masked]
Date: Mon, 02 Apr 2018 18:16:23 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Oleg,

Oleg Pykhalov <[email-masked]> skribis:

> [email-masked] (Ludovic Courtès) writes:
>
>> Ping!
>>
>> [email-masked] (Ludovic Courtès) skribis:
>>
>>> OK for the patch, but please simply replace ‘leave’ with ‘warning’.
>
> I think the patch is no longer needed, because ‘pypi->guix-package’
> returns false (‘#f’) and REPL survives if a package doesn't exist:
>
> scheme@(guix import pypi)> (pypi->guix-package "psutil")
>
> Starting download of /tmp/guix-file.9Q8PGN
> From https://pypi.python.org/packages/e2/e1/600326635f97fee89bf8426fef14c5c29f4849c79f68fd79f433d8c1bd96/psutil-5.4.3.tar.gz...
>  …4.3.tar.gz  403KiB                  1.6MiB/s 00:00 [##################] 100.0%
>
> Starting download of /tmp/guix-file.Vn9nDZ
> From https://pypi.python.org/packages/e5/cc/6dd427e738a8db6d0b66525856da43d2ef12c4c19269863927f7cf0e2aaf/psutil-5.4.3-cp27-none-win32.whl...
>  …7-none-win32.whl  216KiB            1.3MiB/s 00:00 [##################] 100.0%
> $3 = (package (name "python-psutil") #; more fields here)
> scheme@(guix import pypi)> (pypi->guix-package "psutils") ; ‘psutils’ doesn't exist in ‘pypi’
> $4 = #f
>
> WDYT?

Indeed it should no longer be needed.

>> Note that at the REPL you can always do:
>>
>>   (catch 'quit (lambda () …) (const #f))
>
> Thank you!  Based on this I wrote a macro:
>
>    (define-macro (try function)
>     `(catch 'quit (lambda () ,function) (const #f)))
>
> but I don't know how to make it available after invoking ‘guile’ in
> Bash.  Putting the macro in ‘~/.guile’ doesn't help unfortunately.

I just tried and it works for me.  Note that ~/.guile is only read when
starting an interactive Guile (a REPL), not when starting guile to run a
program.

Thanks,
Ludo’.

Subject: [PATCH] import: pypi: Stay in the REPL if fail to get a source
From: Oleg Pykhalov <[email-masked]>
To: [email-masked]
Date: Mon, 25 Dec 2017 16:46:21 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Guix,

If pypi->guix-package fails to get a source release, could we return
false instead of killing a running Guile REPL session?

From 6bb461018fc4cd47d30ab27b5748b9e4cbce6e97 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <[email-masked]>
Date: Mon, 25 Dec 2017 16:32:14 +0300
Subject: [PATCH] import: pypi: Stay in the REPL if fail to get a source
 release.

* guix/import/pypi.scm (pypi->guix-package): Return #f if no source release.
---
 guix/import/pypi.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index bb0db1ba8..3f37ea65f 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -275,9 +275,11 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
     (and package
          (guard (c ((missing-source-error? c)
                     (let ((package (missing-source-error-package c)))
-                      (leave (G_ "no source release for pypi package ~a ~a~%")
-                             (assoc-ref* package "info" "name")
-                             (assoc-ref* package "info" "version")))))
+                      (format (current-error-port)
+                              (G_ "no source release for pypi package ~a ~a~%")
+                              (assoc-ref* package "info" "name")
+                              (assoc-ref* package "info" "version"))
+                      #f)))
            (let ((name (assoc-ref* package "info" "name"))
                  (version (assoc-ref* package "info" "version"))
                  (release (assoc-ref (latest-source-release package) "url"))
-- 
2.15.1

Thanks,
Oleg.