From ff986890ece06b0623a7c8b3048dea1206f076ea Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Thu, 26 Feb 2015 02:07:53 +0100 Subject: import: pypi: Detect inputs. * guix/import/pypi.scm (python->package-name, maybe-inputs, compute-inputs, guess-requirements): New procedures. * guix/import/pypi.scm (guix-hash-url): Now takes a filename instead of an URL as input. * guix/import/pypi.scm (make-pypi-sexp): Now tries to generate the inputs automagically. * tests/pypi.scm: Update the test. --- tests/pypi.scm | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'tests/pypi.scm') diff --git a/tests/pypi.scm b/tests/pypi.scm index 45cf7cac4f..c772474b82 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -21,6 +21,7 @@ #:use-module (guix base32) #:use-module (guix hash) #:use-module (guix tests) + #:use-module ((guix build utils) #:select (delete-file-recursively)) #:use-module (srfi srfi-64) #:use-module (ice-9 match)) @@ -46,8 +47,14 @@ } }") -(define test-source - "foobar") +(define test-source-hash + "") + +(define test-requirements +"# A comment + # A comment after a space +bar +baz > 13.37") (test-begin "pypi") @@ -55,15 +62,22 @@ ;; Replace network resources with sample data. (mock ((guix import utils) url-fetch (lambda (url file-name) - (with-output-to-file file-name - (lambda () - (display - (match url - ("https://pypi.python.org/pypi/foo/json" - test-json) - ("https://example.com/foo-1.0.0.tar.gz" - test-source) - (_ (error "Unexpected URL: " url)))))))) + (match url + ("https://pypi.python.org/pypi/foo/json" + (with-output-to-file file-name + (lambda () + (display test-json)))) + ("https://example.com/foo-1.0.0.tar.gz" + (begin + (mkdir "foo-1.0.0") + (with-output-to-file "foo-1.0.0/requirements.txt" + (lambda () + (display test-requirements))) + (system* "tar" "czvf" file-name "foo-1.0.0/") + (delete-file-recursively "foo-1.0.0") + (set! test-source-hash + (call-with-input-file file-name port-sha256)))) + (_ (error "Unexpected URL: " url))))) (match (pypi->guix-package "foo") (('package ('name "python-foo") @@ -78,13 +92,15 @@ ('build-system 'python-build-system) ('inputs ('quasiquote - (("python-setuptools" ('unquote 'python-setuptools))))) + (("python-bar" ('unquote 'python-bar)) + ("python-baz" ('unquote 'python-baz)) + ("python-setuptools" ('unquote 'python-setuptools))))) ('home-page "http://example.com") ('synopsis "summary") ('description "summary") ('license 'lgpl2.0)) (string=? (bytevector->nix-base32-string - (call-with-input-string test-source port-sha256)) + test-source-hash) hash)) (x (pk 'fail x #f))))) -- cgit v1.2.3