guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/05: import: pypi: Correctly handle multiple-URL origins.


From: Ludovic Courtès
Subject: 03/05: import: pypi: Correctly handle multiple-URL origins.
Date: Wed, 8 Feb 2017 10:17:43 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 4eaac4b722b180b433b75127a30b871aaf9f0913
Author: Ludovic Courtès <address@hidden>
Date:   Wed Feb 8 15:58:36 2017 +0100

    import: pypi: Correctly handle multiple-URL origins.
    
    Fixes <https://bugs.gnu.org/25635>.
    Reported by Sergei Trofimovich <address@hidden>.
    
    * guix/import/pypi.scm (guix-package->pypi-name)[url->pypi-name]: New
    procedure.
    Rewrite body to match lists in addition to strings.
    * tests/pypi.scm ("guix-package->pypi-name, several URLs"): New test.
---
 guix/import/pypi.scm | 13 ++++++++++---
 tests/pypi.scm       | 10 ++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index ed0d429..1e433e3 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 David Thompson <address@hidden>
 ;;; Copyright © 2015 Cyril Roelandt <address@hidden>
-;;; Copyright © 2015, 2016 Ludovic Courtès <address@hidden>
+;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -89,9 +89,16 @@ package."
 (define (guix-package->pypi-name package)
   "Given a Python PACKAGE built from pypi.python.org, return the name of the
 package on PyPI."
-  (let ((source-url (and=> (package-source package) origin-uri)))
+  (define (url->pypi-name url)
     (hyphen-package-name->name+version
-     (basename (file-sans-extension source-url)))))
+     (basename (file-sans-extension url))))
+
+  (match (and=> (package-source package) origin-uri)
+    ((? string? url)
+     (url->pypi-name url))
+    ((lst ...)
+     (any url->pypi-name lst))
+    (#f #f)))
 
 (define (wheel-url->extracted-directory wheel-url)
   (match (string-split (basename wheel-url) #\-)
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 447c23e..a132900 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -22,6 +22,7 @@
   #:use-module (guix base32)
   #:use-module (guix hash)
   #:use-module (guix tests)
+  #:use-module (guix build-system python)
   #:use-module ((guix build utils) #:select (delete-file-recursively which))
   #:use-module (srfi srfi-64)
   #:use-module (ice-9 match))
@@ -90,6 +91,15 @@ baz > 13.37")
                            (uri
                             
"https://pypi.python.org/packages/a2/3b/4756e6a0ceb14e084042a2a65c615d68d25621c6fd446d0fc10d14c4ce7d/certbot-0.8.1.tar.gz";))))))
 
+(test-equal "guix-package->pypi-name, several URLs"
+  "cram"
+  (guix-package->pypi-name
+   (dummy-package "foo"
+                  (source
+                   (dummy-origin
+                    (uri (list "https://bitheap.org/cram/cram-0.7.tar.gz";
+                               (pypi-uri "cram" "0.7"))))))))
+
 (test-assert "pypi->guix-package"
   ;; Replace network resources with sample data.
     (mock ((guix import utils) url-fetch



reply via email to

[Prev in Thread] Current Thread [Next in Thread]