GNU bug report logs - #29847
[PATCH] import: pypi: Stay in the REPL if fail to get a source

Previous Next

Package: guix-patches;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Mon, 25 Dec 2017 13:49:02 UTC

Severity: normal

Tags: patch

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29847 in the body.
You can then email your comments to 29847 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Mon, 25 Dec 2017 13:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 25 Dec 2017 13:49:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: guix-patches <at> gnu.org
Subject: [PATCH] import: pypi: Stay in the REPL if fail to get a source
Date: Mon, 25 Dec 2017 16:46:21 +0300
[Message part 1 (text/plain, inline)]
Hello Guix,

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

[0001-import-pypi-Stay-in-the-REPL-if-fail-to-get-a-source.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Thanks,
Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Mon, 25 Dec 2017 14:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: ng0 <ng0 <at> n0.is>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 29847 <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to
 get a source
Date: Mon, 25 Dec 2017 13:59:46 +0000
[Message part 1 (text/plain, inline)]
Oleg Pykhalov transcribed 2.9K bytes:
> Hello Guix,
> 
> If pypi->guix-package fails to get a source release, could we return
> false instead of killing a running Guile REPL session?
> 

Why? Could you give some reasons why the current behavior is bad
and what your code tries to improve in this regard?

> From 6bb461018fc4cd47d30ab27b5748b9e4cbce6e97 Mon Sep 17 00:00:00 2001
> From: Oleg Pykhalov <go.wigust <at> gmail.com>
> 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.




-- 
GnuPG: A88C8ADD129828D7EAC02E52E22F9BBFEE348588
GnuPG: https://c.n0.is/ng0_pubkeys/tree/keys
  WWW: https://n0.is
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Mon, 25 Dec 2017 15:58:01 GMT) Full text and rfc822 format available.

Message #11 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: ng0 <ng0 <at> n0.is>
Cc: 29847 <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get
 a source
Date: Mon, 25 Dec 2017 18:55:05 +0300
[Message part 1 (text/plain, inline)]
Hello ng0,

ng0 <ng0 <at> n0.is> writes:

> Why? Could you give some reasons why the current behavior is bad
> and what your code tries to improve in this regard?

Because of the documentation string says “return #f on failure” (not
kill REPL on failure or terminate a Guile process):

    Fetch the metadata for PACKAGE-NAME from pypi.python.org, and return the
    `package' s-expression corresponding to that package, or #f on failure.

and because Why an import package function kill my Emacs's Geiser?  :'(


I'm trying to implement recursive-import for pypi based on cran's
recursive-import.  Killing Guile process will be an issue, I guess.

Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Mon, 25 Dec 2017 19:39:02 GMT) Full text and rfc822 format available.

Message #14 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: ng0 <ng0 <at> n0.is>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 29847 <at> debbugs.gnu.org, ng0 <ng0 <at> n0.is>
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to
 get a source
Date: Mon, 25 Dec 2017 19:38:25 +0000
[Message part 1 (text/plain, inline)]
Hi,

Oleg Pykhalov transcribed 1.6K bytes:
> Hello ng0,
> 
> ng0 <ng0 <at> n0.is> writes:
> 
> > Why? Could you give some reasons why the current behavior is bad
> > and what your code tries to improve in this regard?
> 
> Because of the documentation string says “return #f on failure” (not
> kill REPL on failure or terminate a Guile process):
> 
>     Fetch the metadata for PACKAGE-NAME from pypi.python.org, and return the
>     `package' s-expression corresponding to that package, or #f on failure.
> 
> and because Why an import package function kill my Emacs's Geiser?  :'(
> 
> 
> I'm trying to implement recursive-import for pypi based on cran's
> recursive-import.  Killing Guile process will be an issue, I guess.
> 
> Oleg.

Okay, sounds reasonable. I just thought an explanation would be
good. Preferable we should add those to the commits more often.
Context is good :)

-- 
GnuPG: A88C8ADD129828D7EAC02E52E22F9BBFEE348588
GnuPG: https://c.n0.is/ng0_pubkeys/tree/keys
  WWW: https://n0.is
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Fri, 29 Dec 2017 11:15:02 GMT) Full text and rfc822 format available.

Message #17 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 29847 <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to
 get a source
Date: Fri, 29 Dec 2017 12:14:22 +0100
On Mon, 25 Dec 2017 16:46:21 +0300
Oleg Pykhalov <go.wigust <at> gmail.com> wrote:

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

LGTM!




Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Thu, 11 Jan 2018 21:41:02 GMT) Full text and rfc822 format available.

Message #20 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 29847 <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get
 a source
Date: Thu, 11 Jan 2018 22:39:59 +0100
Hi Oleg,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

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

Note that at the REPL you can always do:

  (catch 'quit (lambda () …) (const #f))

>           (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)))

OK for the patch, but please simply replace ‘leave’ with ‘warning’.

Note that for me the motivation is not to avoid exiting REPLs since it’s
easy to avoid anyway.  The motivation is rather to make it easier to
integrate importers in applications other than ‘guix import’: ‘guix
refresh’ is one of them, but then I’d also like importers/updaters to be
directly used from ‘guix package’.  For that, it’s a good idea to avoid
calling ‘exit’ on the first occasion, obviously.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Thu, 29 Mar 2018 13:17:02 GMT) Full text and rfc822 format available.

Message #23 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 29847 <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get
 a source
Date: Thu, 29 Mar 2018 15:16:53 +0200
Ping!

ludo <at> gnu.org (Ludovic Courtès) skribis:

> Hi Oleg,
>
> Oleg Pykhalov <go.wigust <at> gmail.com> skribis:
>
>> If pypi->guix-package fails to get a source release, could we return
>> false instead of killing a running Guile REPL session?
>
> Note that at the REPL you can always do:
>
>   (catch 'quit (lambda () …) (const #f))
>
>>           (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)))
>
> OK for the patch, but please simply replace ‘leave’ with ‘warning’.
>
> Note that for me the motivation is not to avoid exiting REPLs since it’s
> easy to avoid anyway.  The motivation is rather to make it easier to
> integrate importers in applications other than ‘guix import’: ‘guix
> refresh’ is one of them, but then I’d also like importers/updaters to be
> directly used from ‘guix package’.  For that, it’s a good idea to avoid
> calling ‘exit’ on the first occasion, obviously.
>
> Thanks,
> Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#29847; Package guix-patches. (Sun, 01 Apr 2018 13:27:02 GMT) Full text and rfc822 format available.

Message #26 received at 29847 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 29847 <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get
 a source
Date: Sun, 01 Apr 2018 16:26:38 +0300
[Message part 1 (text/plain, inline)]
Hello Ludovic,

Apologies for a long reply.

ludo <at> gnu.org (Ludovic Courtès) writes:

> Ping!
>
> ludo <at> gnu.org (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:
--8<---------------cut here---------------start------------->8---
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
--8<---------------cut here---------------end--------------->8---

WDYT?

> 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.

Thanks,
Oleg.
[signature.asc (application/pgp-signature, inline)]

Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Mon, 02 Apr 2018 16:17:02 GMT) Full text and rfc822 format available.

Notification sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
bug acknowledged by developer. (Mon, 02 Apr 2018 16:17:02 GMT) Full text and rfc822 format available.

Message #31 received at 29847-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 29847-done <at> debbugs.gnu.org
Subject: Re: [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get
 a source
Date: Mon, 02 Apr 2018 18:16:23 +0200
Hi Oleg,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> Ping!
>>
>> ludo <at> gnu.org (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’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 01 May 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 360 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.