[bug#77600] import/pypi: Improve renaming procedure.

Message ID ef26b85421faf0b61ee1e8e96063da96bac3835e.1744010429.git.maxim.cournoyer@gmail.com
State New
Headers
Series [bug#77600] import/pypi: Improve renaming procedure. |

Commit Message

Maxim Cournoyer April 7, 2025, 7:20 a.m. UTC
  A package named upstream like 'tmdb-python' now gets named 'python-tmdb'
instead of 'python-tmdb-python', which is ugly and doesn't match our
convention (info "(guix) Python Modules").

* guix/import/pypi.scm (python->package-name): Turn a -python suffix into a
python- prefix.

Change-Id: I7c0227d569c0afe6b16329d7cedb51728e4365b0
---
 guix/import/pypi.scm | 2 ++
 1 file changed, 2 insertions(+)


base-commit: e2f37229e5e7f6e73806d8087faf9e1e94ea9acf
  

Comments

Sharlatan Hellseher April 7, 2025, 4:35 p.m. UTC | #1
Hi,

The change looks reasonable.

Some side note on PyPI source archive naming, they started forcing
users to rename them to lower case only and _

https://packaging.python.org/en/latest/discussions/package-formats/

VCS: https://github.incerto.xyz/; https://git.sr.ht/~hellseher/
GPG: 9847 81DE 689C 21C2 6418 0867 76D7 27BF F62C D2B5

… наш разум - превосходная объяснительная машина которая способна найти
смысл почти в чем угодно, истолковать любой феномен, но совершенно не в
состоянии принять мысль о непредсказуемости.
  
Maxim Cournoyer April 14, 2025, 6:40 a.m. UTC | #2
Hi,

Sharlatan Hellseher <sharlatanus@gmail.com> writes:

> Hi,
>
> The change looks reasonable.
>
> Some side note on PyPI source archive naming, they started forcing
> users to rename them to lower case only and _

OK, thanks for looking.  About the later naming, that's something to
handle in `guix-package->pypi-name', right?  I'm not sure this happens
*everywhere* for new releases now, on only in packages using modern
packaging tools such PEP 517 builders, though?

I've now applied this one.
  

Patch

diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index dd43ebdcf3..5e2c6ec9ff 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -179,6 +179,8 @@  (define (python->package-name name)
 package."
   (cond
    ((string-prefix? "python-" name) (snake-case name))
+   ((string-suffix? "-python" name)
+    (string-append "python-" (string-drop-right name 7)))
    ((or (string=? "trytond" name)
         (string-prefix? "trytond-" name)) (snake-case name))
    (else (string-append "python-" (snake-case name)))))