unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#53395] Fix pypi import for flake8-array-spacing
@ 2022-01-20 19:45 Vivien Kraus via Guix-patches via
  2022-01-24 14:05 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Vivien Kraus via Guix-patches via @ 2022-01-20 19:45 UTC (permalink / raw)
  To: 53395


[-- Attachment #1.1: Type: text/plain, Size: 253 bytes --]


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Fix the pypi importer --]
[-- Type: text/x-patch, Size: 2664 bytes --]

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(-)

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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-26 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 19:45 [bug#53395] Fix pypi import for flake8-array-spacing Vivien Kraus via Guix-patches via
2022-01-24 14:05 ` Ludovic Courtès
2022-01-24 22:07   ` Vivien Kraus via Guix-patches via
2022-01-25 13:19     ` Ludovic Courtès
2022-01-25 16:39       ` Vivien Kraus via Guix-patches via
2022-01-26 15:20         ` bug#53395: " 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).