* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
@ 2017-12-25 13:46 Oleg Pykhalov
2017-12-25 13:59 ` ng0
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Oleg Pykhalov @ 2017-12-25 13:46 UTC (permalink / raw)
To: 29847
[-- Attachment #1.1: Type: text/plain, Size: 138 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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: [PATCH] import: pypi: Stay in the REPL if fail to get a source --]
[-- Type: text/x-patch, Size: 1535 bytes --]
From 6bb461018fc4cd47d30ab27b5748b9e4cbce6e97 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <go.wigust@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
[-- Attachment #1.3: Type: text/plain, Size: 15 bytes --]
Thanks,
Oleg.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2017-12-25 13:46 [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source Oleg Pykhalov
@ 2017-12-25 13:59 ` ng0
2017-12-25 15:55 ` Oleg Pykhalov
2017-12-29 11:14 ` Danny Milosavljevic
2018-01-11 21:39 ` Ludovic Courtès
2 siblings, 1 reply; 9+ messages in thread
From: ng0 @ 2017-12-25 13:59 UTC (permalink / raw)
To: Oleg Pykhalov; +Cc: 29847
[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]
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@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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2017-12-25 13:59 ` ng0
@ 2017-12-25 15:55 ` Oleg Pykhalov
2017-12-25 19:38 ` ng0
0 siblings, 1 reply; 9+ messages in thread
From: Oleg Pykhalov @ 2017-12-25 15:55 UTC (permalink / raw)
To: ng0; +Cc: 29847
[-- Attachment #1: Type: text/plain, Size: 674 bytes --]
Hello ng0,
ng0 <ng0@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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2017-12-25 15:55 ` Oleg Pykhalov
@ 2017-12-25 19:38 ` ng0
0 siblings, 0 replies; 9+ messages in thread
From: ng0 @ 2017-12-25 19:38 UTC (permalink / raw)
To: Oleg Pykhalov; +Cc: 29847
[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]
Hi,
Oleg Pykhalov transcribed 1.6K bytes:
> Hello ng0,
>
> ng0 <ng0@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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2017-12-25 13:46 [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source Oleg Pykhalov
2017-12-25 13:59 ` ng0
@ 2017-12-29 11:14 ` Danny Milosavljevic
2018-01-11 21:39 ` Ludovic Courtès
2 siblings, 0 replies; 9+ messages in thread
From: Danny Milosavljevic @ 2017-12-29 11:14 UTC (permalink / raw)
To: Oleg Pykhalov; +Cc: 29847
On Mon, 25 Dec 2017 16:46:21 +0300
Oleg Pykhalov <go.wigust@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!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2017-12-25 13:46 [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source Oleg Pykhalov
2017-12-25 13:59 ` ng0
2017-12-29 11:14 ` Danny Milosavljevic
@ 2018-01-11 21:39 ` Ludovic Courtès
2018-03-29 13:16 ` Ludovic Courtès
2 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2018-01-11 21:39 UTC (permalink / raw)
To: Oleg Pykhalov; +Cc: 29847
Hi Oleg,
Oleg Pykhalov <go.wigust@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’.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2018-01-11 21:39 ` Ludovic Courtès
@ 2018-03-29 13:16 ` Ludovic Courtès
2018-04-01 13:26 ` Oleg Pykhalov
0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2018-03-29 13:16 UTC (permalink / raw)
To: Oleg Pykhalov; +Cc: 29847
Ping!
ludo@gnu.org (Ludovic Courtès) skribis:
> Hi Oleg,
>
> Oleg Pykhalov <go.wigust@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’.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source
2018-03-29 13:16 ` Ludovic Courtès
@ 2018-04-01 13:26 ` Oleg Pykhalov
2018-04-02 16:16 ` bug#29847: " Ludovic Courtès
0 siblings, 1 reply; 9+ messages in thread
From: Oleg Pykhalov @ 2018-04-01 13:26 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 29847
[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]
Hello Ludovic,
Apologies for a long reply.
ludo@gnu.org (Ludovic Courtès) writes:
> Ping!
>
> ludo@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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#29847: [PATCH] import: pypi: Stay in the REPL if fail to get a source
2018-04-01 13:26 ` Oleg Pykhalov
@ 2018-04-02 16:16 ` Ludovic Courtès
0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2018-04-02 16:16 UTC (permalink / raw)
To: Oleg Pykhalov; +Cc: 29847-done
Hi Oleg,
Oleg Pykhalov <go.wigust@gmail.com> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Ping!
>>
>> ludo@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’.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-04-02 16:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-25 13:46 [bug#29847] [PATCH] import: pypi: Stay in the REPL if fail to get a source Oleg Pykhalov
2017-12-25 13:59 ` ng0
2017-12-25 15:55 ` Oleg Pykhalov
2017-12-25 19:38 ` ng0
2017-12-29 11:14 ` Danny Milosavljevic
2018-01-11 21:39 ` Ludovic Courtès
2018-03-29 13:16 ` Ludovic Courtès
2018-04-01 13:26 ` Oleg Pykhalov
2018-04-02 16:16 ` bug#29847: " Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).