Vivien Kraus wrote 3 years ago
(address . guix-patches@gnu.org)
Dear guix,
flake8-array-spacing is a funny package because its download URI uses a
base name of flake8_array_spacing. Apparently some other packages have
similar features, appearing as the downcase version.
What do you think?
Best regards,
Vivien
From d8923c394fbe2e8eedf6fa548455d398f0caa022 Mon Sep 17 00:00:00 2001
From: Vivien Kraus <vivien@planete-kraus.eu>
Date: Thu, 20 Jan 2022 20:11:56 +0100
Subject: [PATCH] pypi importer: Convert - to _ in pypi urls if needed.
* guix/import/pypi.scm (find-project-url): New function.
(make-pypi-sexp): Use find-project-url.
---
guix/import/pypi.scm | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
Toggle diff (43 lines)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index b4284f5c33..fd176e65d5 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -418,6 +418,19 @@ (define process-requirements
(values (map process-requirements dependencies)
(concatenate dependencies))))
+(define (find-project-url name pypi-url)
+ "Try different project name substitution until the result is found in
+pypi-url. Downcase is required for \"Deprecated\" and \"uWSGI\", and
+underscores are required for flake8-array-spacing."
+ (or (find (cut string-contains pypi-url <>)
+ (list name
+ (string-downcase name)
+ (string-replace-substring name "-" "_")))
+ (begin
+ (warning (G_ "The project name `~a' does not appear in the pypi URL; you might need to fix the pypi-url declaration in the generated package. The URL is: ~a~%")
+ name pypi-url)
+ name)))
+
(define (make-pypi-sexp name version source-url wheel-url home-page synopsis
description license)
"Return the `package' s-expression for a python package with the given NAME,
@@ -446,15 +459,7 @@ (define (maybe-upstream-name name)
(origin
(method url-fetch)
(uri (pypi-uri
- ;; PyPI URL are case sensitive, but sometimes
- ;; a project named using mixed case has a URL
- ;; using lower case, so we must work around this
- ;; inconsistency. For actual examples, compare
- ;; the URLs of the "Deprecated" and "uWSGI" PyPI
- ;; packages.
- ,(if (string-contains source-url name)
- name
- (string-downcase name))
+ ,(find-project-url name source-url)
version
;; Some packages have been released as `.zip`
;; instead of the more common `.tar.gz`. For
--
2.34.0
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCAAdFiEEq4yIHjMvkliPpwQnO7C8EjLYuCwFAmHpu88ACgkQO7C8EjLY
uCyfzwwAmJfEk+jF6rgzGBgUrYeDoNzc0nPoDCysNlOnQJ/NlgDRJhQ76FVgcaom
/gYf9iToOqevo5+qsrw0Qldp2nzyREVf63WmU4fpANhM1e7OUxwkKtBJItEiqR9t
ymva2WMkxL3/6BxIFJZiLkHK1T+odxtT2C391EJoxS92NlVHcWkFJr1T0PkrxTMo
Iqdd8/JbO/+MEXunHtFnPkXfIqfhrvhP/QzBLj5N6RHgeL5mLAdQc5/sxr8B0NO1
4u2mkCaJoOgzGVttti4ZStYR+P8EwqXwYqosk9PK/FdC2iLEKwIhSGTRycyX6FRM
vsqAtgjn+FoefNmqFoRWdB7/I3aEK18s4FWBQAZ88J6gunX+OmJNR0+YvlXzmBOr
LFw2nUtw15t6YXhZdD02/gUGRjx4XZM+DeAadFKdMmSogdedCrMmaA2//s/1OieJ
zBD3MEr69xOQ4nA/En6oMG9qECMlox1PTSj4BF+HTuKql6ZECA9diPDcUr/RCZRe
12FS3I/N
=/Fqc
-----END PGP SIGNATURE-----