diff mbox series

[bug#56433] import: pypi: Add special treatment for Tryton package names,

Message ID 026f292cc13e95239135786a8ad830a29d483e41.1657187223.git.h.goebel@crazy-compilers.com
State Accepted
Headers show
Series [bug#56433] import: pypi: Add special treatment for Tryton package names, | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Hartmut Goebel July 7, 2022, 9:47 a.m. UTC
While Trytond modules are Python package, they don't have the "python-"
prefix (see also https://issues.guix.gnu.org/46057#1).  This patch disables
adding the prefix for Trytond modules when importing and updating, thus
inhibiting irritating messages like „consider removing this propagated input:
trytond-party, consider adding this propagated input: python-trytond-party“.

Handling this a special case seems appropriate since (as of now) there are
about 165 packages for Trytond and the number is growing.

* guix/import/pypi.scm(python->package-name): Don't add "python-" prefix for
  trytond packages.
---
 guix/import/pypi.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)


base-commit: 2b883504288fc48ed1ae80620e664fe5216766c7

Comments

Munyoki Kilyungi July 8, 2022, 10:36 a.m. UTC | #1
Hartmut Goebel <h.goebel@crazy-compilers.com>
anaandika:

> While Trytond modules are Python package, they don't have the "python-"
> prefix (see also https://issues.guix.gnu.org/46057#1).  This patch disables
> adding the prefix for Trytond modules when importing and updating, thus
> inhibiting irritating messages like „consider removing this propagated input:
> trytond-party, consider adding this propagated input: python-trytond-party“.
>
> Handling this a special case seems appropriate since (as of now) there are
> about 165 packages for Trytond and the number is growing.
>
> * guix/import/pypi.scm(python->package-name): Don't add "python-" prefix for
>   trytond packages.
> ---
>  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 130ec769b3..ee74f6065c 100644
> --- a/guix/import/pypi.scm
> +++ b/guix/import/pypi.scm
> @@ -162,9 +162,11 @@ or #f if there isn't any."
>  (define (python->package-name name)
>    "Given the NAME of a package on PyPI, return a Guix-compliant name for the
>  package."
> -  (if (string-prefix? "python-" name)
> -      (snake-case name)
> -      (string-append "python-" (snake-case name))))
> +  (cond
> +   ((string-prefix? "python-" name) (snake-case name))
> +   ((or (string=? "trytond" name)
> +        (string-prefix? "trytond-" name)) (snake-case name))
> +   (#t (string-append "python-" (snake-case name)))))
>

In this case shouldn't you use an "else" at the
very end of this 'cond'?

>  (define (guix-package->pypi-name package)
>    "Given a Python PACKAGE built from pypi.org, return the name of the
>
> base-commit: 2b883504288fc48ed1ae80620e664fe5216766c7


-- 
(Life is like a pencil that will surely run out,
    but will leave the beautiful writing of life.)
(D4F09EB110177E03C28E2FE1F5BBAE1E0392253F
    (hkp://keys.gnupg.net))
Hartmut Goebel July 8, 2022, 11:30 a.m. UTC | #2
Am 08.07.22 um 12:36 schrieb Munyoki Kilyungi:
> In this case shouldn't you use an "else" at the very end of this 'cond'?

Of course.

I missed this when reading the documentation of „cond“ 
https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/if-cond-case.html 
and was wondering about it. Thanks for the nit-pick.
Ludovic Courtès July 8, 2022, 9:36 p.m. UTC | #3
Hi Hartmut,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> I missed this when reading the documentation of „cond“
> https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/if-cond-case.html
> and was wondering about it. Thanks for the nit-pick.

This is the Guile 1.8 documentation (last 1.8 release was in 2010).
Check out <https://gnu.org/s/guile/manual/html_node> for the current
version, or just ‘info guile’ on your machine.

Ludo’.
Ludovic Courtès July 8, 2022, 9:37 p.m. UTC | #4
Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> While Trytond modules are Python package, they don't have the "python-"
> prefix (see also https://issues.guix.gnu.org/46057#1).  This patch disables
> adding the prefix for Trytond modules when importing and updating, thus
> inhibiting irritating messages like „consider removing this propagated input:
> trytond-party, consider adding this propagated input: python-trytond-party“.

Could you instead add an ‘upstream-name’ property to these packages?
That’d be explicit and IMO clearer.

Ludo’.
Hartmut Goebel July 11, 2022, 1:49 p.m. UTC | #5
Am 08.07.22 um 23:37 schrieb Ludovic Courtès:
> Could you instead add an ‘upstream-name’ property to these packages?
> That’d be explicit and IMO clearer.

AFAIU the „upstream-name“ property changes the name when requesting the 
upstream source or when updating.

This fix works into the opposite direction: it fixes the 
„downstream“-name = the guix package name.

Name at pypi:

  * „normal“ Python package: myCoolModule
  * Trytond package: trytond-cool_addon.

Name at guix:

  * „normal“ Python package: python-mycoolmodule — “python-” prefix
  * Trytond package: trytond-cool-addon — no “python-” prefix

Looks like this is not clear from the commit message. Does this changed 
message make it clear?


Trytond modules are Python packages, and treated like this in guix.
Anyhow, since they are add-ons for the “Trytond“ application,
their guix package name do not get the "python-" prefix like other 
Python modules, (see also https://issues.guix.gnu.org/46057#1). This 
change disables
adding the "python-" prefix to the guix packge name for Trytond modules
when importing and updating, thus
inhibiting irritating messages like „consider removing this propagated 
input:
trytond-party, consider adding this propagated input: python-trytond-party“.
Ludovic Courtès July 11, 2022, 7:54 p.m. UTC | #6
Hi,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> AFAIU the „upstream-name“ property changes the name when requesting
> the upstream source or when updating.

The ‘upstream-name’ property establishes a mapping between the package
at hand and its upstream name, overriding guesswork normally done by
importers and updaters.

> This fix works into the opposite direction: it fixes the
> „downstream“-name = the guix package name.
>
> Name at pypi:
>
>  * „normal“ Python package: myCoolModule
>  * Trytond package: trytond-cool_addon.
>
> Name at guix:
>
>  * „normal“ Python package: python-mycoolmodule — “python-” prefix
>  * Trytond package: trytond-cool-addon — no “python-” prefix

Ooh, got it.  So yes, this patch makes sense to me.  (I’m surprised we
decided against the “python-” prefix back then, but that’s history.)

> Looks like this is not clear from the commit message. Does this
> changed message make it clear?

I think the commit message is fine, but…

> Trytond modules are Python packages, and treated like this in guix.
> Anyhow, since they are add-ons for the “Trytond“ application,
> their guix package name do not get the "python-" prefix like other
> Python modules, (see also https://issues.guix.gnu.org/46057#1). This
> change disables
> adding the "python-" prefix to the guix packge name for Trytond modules
> when importing and updating, thus
> inhibiting irritating messages like „consider removing this propagated
> input:
> trytond-party, consider adding this propagated input: python-trytond-party“.

… I’m not sure I fully understand this part: you’re talking about
messages produced by ‘guix refresh’, right?  Do you have the example of
a command that triggers this?

Perhaps you can include that example in the commit message to make
things perfectly clear.

Anyway, LGTM, thanks!

Ludo’.
Hartmut Goebel July 15, 2022, 7:16 p.m. UTC | #7
Thanks for the review. As you suggested, I added an example and pushed 
as 2e0b7867fe89fcfb0523a85635ecc3e1f9484fcd
diff mbox series

Patch

diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 130ec769b3..ee74f6065c 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -162,9 +162,11 @@  or #f if there isn't any."
 (define (python->package-name name)
   "Given the NAME of a package on PyPI, return a Guix-compliant name for the
 package."
-  (if (string-prefix? "python-" name)
-      (snake-case name)
-      (string-append "python-" (snake-case name))))
+  (cond
+   ((string-prefix? "python-" name) (snake-case name))
+   ((or (string=? "trytond" name)
+        (string-prefix? "trytond-" name)) (snake-case name))
+   (#t (string-append "python-" (snake-case name)))))
 
 (define (guix-package->pypi-name package)
   "Given a Python PACKAGE built from pypi.org, return the name of the