aboutsummaryrefslogtreecommitdiff
path: root/guix/import/pypi.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-02-08 15:58:36 +0100
committerLudovic Courtès <ludo@gnu.org>2017-02-08 16:17:05 +0100
commit4eaac4b722b180b433b75127a30b871aaf9f0913 (patch)
tree07709e7514f1db6fd9aadaeb8cd1fb74b3717189 /guix/import/pypi.scm
parent750a423996f3471aa4807609256f686c8ebf5584 (diff)
downloadgnu-guix-4eaac4b722b180b433b75127a30b871aaf9f0913.tar
gnu-guix-4eaac4b722b180b433b75127a30b871aaf9f0913.tar.gz
import: pypi: Correctly handle multiple-URL origins.
Fixes <https://bugs.gnu.org/25635>. Reported by Sergei Trofimovich <slyfox@inbox.ru>. * 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.
Diffstat (limited to 'guix/import/pypi.scm')
-rw-r--r--guix/import/pypi.scm13
1 files changed, 10 insertions, 3 deletions
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index ed0d4297a4..1e433e3fb3 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 <davet@gnu.org>
;;; Copyright © 2015 Cyril Roelandt <tipecaml@gmail.com>
-;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;;
;;; 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) #\-)