all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Cyril Roelandt <tipecaml@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 4/5] import: pypi: Compute test requirements when reading requirements files.
Date: Sat, 16 Jul 2016 17:23:24 +0200	[thread overview]
Message-ID: <1468682605-12622-5-git-send-email-tipecaml@gmail.com> (raw)
In-Reply-To: <1468682605-12622-1-git-send-email-tipecaml@gmail.com>

* 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

  parent reply	other threads:[~2016-07-16 15:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-16 15:23 [PATCH 0/5] Improve the pypi updater Cyril Roelandt
2016-07-16 15:23 ` [PATCH 1/5] import: pypi: Move runtime dependencies to the propagated-inputs Cyril Roelandt
2016-07-16 15:23 ` [PATCH 2/5] import: pypi: Remove setuptools from the inputs Cyril Roelandt
2016-07-22 21:24   ` Ludovic Courtès
2016-07-22 21:43     ` Leo Famulari
2016-07-23 14:46       ` Cyril Roelandt
2016-07-25 21:07         ` Ludovic Courtès
2016-07-16 15:23 ` [PATCH 3/5] import: pypi: Compute test requirements when using wheels Cyril Roelandt
2016-07-22 21:28   ` Ludovic Courtès
2016-07-16 15:23 ` Cyril Roelandt [this message]
2016-07-22 21:30   ` [PATCH 4/5] import: pypi: Compute test requirements when reading requirements files Ludovic Courtès
2016-07-23 14:48     ` Cyril Roelandt
2016-07-25 21:12       ` Ludovic Courtès
2016-07-16 15:23 ` [PATCH 5/5] import: pypi: Add more tests Cyril Roelandt
2016-07-22 21:31   ` Ludovic Courtès
2016-07-17 16:30 ` [PATCH 0/5] Improve the pypi updater Hartmut Goebel
2016-07-22 21:22 ` Ludovic Courtès
2016-07-23 14:53   ` Cyril Roelandt
2016-07-25 21:14     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468682605-12622-5-git-send-email-tipecaml@gmail.com \
    --to=tipecaml@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.