import/pypi: Improve renaming procedure.

PyPI canonicalizes dashes to underscores, while the former tests for
converting to Guix-compliant name compared using dashes.  Solve this by
canonicalizing to dashes prior to comparing.

* guix/import/pypi.scm (python->package-name): Canonicalize names prior to
testing.

Change-Id: Iba2003720adba82a7f6e3f6319b2699e369163ed
This commit is contained in:
Hartmut Goebel 2025-09-23 19:10:17 +02:00
parent 803964399c
commit faac1c2bf0
No known key found for this signature in database
GPG key ID: 634A8DFFD3F631DF

View file

@ -183,13 +183,14 @@ or #f if there isn't any."
(define (python->package-name name) (define (python->package-name name)
"Given the NAME of a package on PyPI, return a Guix-compliant name for the "Given the NAME of a package on PyPI, return a Guix-compliant name for the
package." package."
(cond (let ((name (snake-case name)))
((string-prefix? "python-" name) (snake-case name)) (cond
((string-suffix? "-python" name) ((string-prefix? "python-" name) name)
(string-append "python-" (string-drop-right name 7))) ((string-suffix? "-python" name)
((or (string=? "trytond" name) (string-append "python-" (string-drop-right name 7)))
(string-prefix? "trytond-" name)) (snake-case name)) ((or (string=? "trytond" name)
(else (string-append "python-" (snake-case name))))) (string-prefix? "trytond-" name)) name)
(else (string-append "python-" name)))))
(define (guix-package->pypi-name package) (define (guix-package->pypi-name package)
"Given a Python PACKAGE built from pypi.org, return the name of the "Given a Python PACKAGE built from pypi.org, return the name of the