From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyril Roelandt Subject: [PATCH 4/5] import: pypi: Compute test requirements when reading requirements files. Date: Sat, 16 Jul 2016 17:23:24 +0200 Message-ID: <1468682605-12622-5-git-send-email-tipecaml@gmail.com> References: <1468682605-12622-1-git-send-email-tipecaml@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bORRN-0006JO-Sv for guix-devel@gnu.org; Sat, 16 Jul 2016 11:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bORRL-0003jF-IB for guix-devel@gnu.org; Sat, 16 Jul 2016 11:23:40 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bORRL-0003j2-6k for guix-devel@gnu.org; Sat, 16 Jul 2016 11:23:39 -0400 Received: by mail-wm0-x244.google.com with SMTP id q128so6112769wma.1 for ; Sat, 16 Jul 2016 08:23:39 -0700 (PDT) In-Reply-To: <1468682605-12622-1-git-send-email-tipecaml@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * 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