* guix/import/pypi.scm (guess-requirement-from-source): Read test-requirements.txt as well as requirements.txt. * tests/pypi.scm ("pypi->guix-package"): Update accordingly. --- guix/import/pypi.scm | 20 +++++++++++++++----- tests/pypi.scm | 11 +++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index f43d7d5..917713d 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -210,16 +210,26 @@ cannot determine package dependencies")) (let ((dirname (tarball-directory source-url))) (if (string? dirname) (let* ((req-file (string-append dirname "/requirements.txt")) - (exit-code (system* "tar" "xf" tarball req-file))) + (test-req-file (string-append dirname "/test-requirements.txt")) + (exit-code (system* "tar" "xf" tarball req-file)) + (test-exit-code (system* "tar" "xf" tarball test-req-file))) ;; TODO: support more formats. - (if (zero? exit-code) + (if (or (zero? exit-code) + (zero? test-exit-code)) (dynamic-wind (const #t) (lambda () - (list (read-requirements req-file) - '())) + (list (if (zero? exit-code) + (read-requirements req-file) + '()) + (if (zero? test-exit-code) + (read-requirements test-req-file) + '()))) (lambda () - (delete-file req-file) + (when (zero? exit-code) + (delete-file req-file)) + (when (zero? test-exit-code) + (delete-file test-req-file)) (rmdir dirname))) (begin (warning (_ "'tar xf' failed with exit code ~a\n") diff --git a/tests/pypi.scm b/tests/pypi.scm index cbf7066..7a38d6e 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -59,6 +59,10 @@ bar baz > 13.37") +(define test-test-requirements +"test-bar +test-baz > 42.42") + (define test-metadata "{ \"run_requires\": [ @@ -96,6 +100,9 @@ baz > 13.37") (with-output-to-file "foo-1.0.0/requirements.txt" (lambda () (display test-requirements))) + (with-output-to-file "foo-1.0.0/test-requirements.txt" + (lambda () + (display test-test-requirements))) (system* "tar" "czvf" file-name "foo-1.0.0/") (delete-file-recursively "foo-1.0.0") (set! test-source-hash @@ -118,6 +125,10 @@ baz > 13.37") ('quasiquote (("python-bar" ('unquote 'python-bar)) ("python-baz" ('unquote 'python-baz))))) + ('native-inputs + ('quasiquote + (("python-test-bar" ('unquote 'python-test-bar)) + ("python-test-baz" ('unquote 'python-test-baz))))) ('home-page "http://example.com") ('synopsis "summary") ('description "summary") -- 2.6.2