From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyril Roelandt Subject: [PATCH 3/5] import: pypi: Compute test requirements when using wheels. Date: Sat, 16 Jul 2016 17:23:23 +0200 Message-ID: <1468682605-12622-4-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]:57116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bORRN-0006Ih-9d for guix-devel@gnu.org; Sat, 16 Jul 2016 11:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bORRK-0003ix-O8 for guix-devel@gnu.org; Sat, 16 Jul 2016 11:23:40 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bORRK-0003in-DA for guix-devel@gnu.org; Sat, 16 Jul 2016 11:23:38 -0400 Received: by mail-wm0-x242.google.com with SMTP id i5so6093985wmg.2 for ; Sat, 16 Jul 2016 08:23:38 -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 (read-wheel-metadata): Read test requirements from the metadata included in the wheel. * guix/import/pypi.scm (guess-requirement-from-source): Return an empty list for test requirements. * guix/import/pypi.scm (compute-inputs): Return both the runtime requirements and the test requirements. * guix/import.pypi.scm (make-pypi-sexp): Compute native inputs. * tests/pypi.scm ("pypi->guix-package, wheels"): Update accordingly. --- guix/import/pypi.scm | 96 +++++++++++++++++++++++++++++----------------------- tests/pypi.scm | 12 +++++++ 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index af9b108..f43d7d5 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -175,13 +175,21 @@ cannot determine package dependencies")) (lambda (port) (let* ((metadata (json->scm port)) (run_requires (hash-ref metadata "run_requires")) + (test_requires (hash-ref metadata "test_requires")) (requirements (if run_requires (hash-ref (list-ref run_requires 0) "requires") - '()))) - (map (lambda (r) - (python->package-name (clean-requirement r))) - requirements))))) + '())) + (test-requirements (if test_requires + (hash-ref (list-ref test_requires 0) + "requires") + '()))) + (list (map (lambda (r) + (python->package-name (clean-requirement r))) + requirements) + (map (lambda (r) + (python->package-name (clean-requirement r))) + test-requirements)))))) (lambda () (delete-file json-file) (rmdir dirname)))))) @@ -208,15 +216,16 @@ cannot determine package dependencies")) (dynamic-wind (const #t) (lambda () - (read-requirements req-file)) + (list (read-requirements req-file) + '())) (lambda () (delete-file req-file) (rmdir dirname))) (begin (warning (_ "'tar xf' failed with exit code ~a\n") exit-code) - '()))) - '()))) + (list '() '())))) + (list '() '())))) ;; First, try to compute the requirements using the wheel, since that is the ;; most reliable option. If a wheel is not provided for this package, try @@ -228,17 +237,21 @@ cannot determine package dependencies")) (define (compute-inputs source-url wheel-url tarball) "Given the SOURCE-URL of an already downloaded TARBALL, return a list of -name/variable pairs describing the required inputs of this package." - (sort - (map (lambda (input) - (list input (list 'unquote (string->symbol input)))) - ;; Argparse has been part of Python since 2.7. - (remove (cut string=? "python-argparse" <>) - (guess-requirements source-url wheel-url tarball))) - (lambda args - (match args - (((a _ ...) (b _ ...)) - (string-cisymbol input)))) + ;; Argparse has been part of Python since 2.7. + (remove (cut string=? "python-argparse" <>) + inputs)) + (lambda args + (match args + (((a _ ...) (b _ ...)) + (string-cipackage-name name)) - (version ,version) - (source (origin - (method url-fetch) - - ;; Sometimes 'pypi-uri' doesn't quite work due to mixed - ;; cases in NAME, for instance, as is the case with - ;; "uwsgi". In that case, fall back to a full URL. - (uri ,(if (equal? (pypi-uri name version) source-url) - `(pypi-uri ,name version) - `(string-append - ,@(factorize-uri source-url version)))) - - (sha256 - (base32 - ,(guix-hash-url temp))))) - (build-system python-build-system) - ,@(maybe-inputs 'propagated-inputs - (compute-inputs source-url wheel-url temp)) - (home-page ,home-page) - (synopsis ,synopsis) - (description ,description) - (license ,(license->symbol license))))))) + (let ((inputs (compute-inputs source-url wheel-url temp))) + `(package + (name ,(python->package-name name)) + (version ,version) + (source (origin + (method url-fetch) + ;; Sometimes 'pypi-uri' doesn't quite work due to mixed + ;; cases in NAME, for instance, as is the case with + ;; "uwsgi". In that case, fall back to a full URL. + (uri ,(if (equal? (pypi-uri name version) source-url) + `(pypi-uri ,name version) + `(string-append + ,@(factorize-uri source-url version)))) + (sha256 + (base32 + ,(guix-hash-url temp))))) + (build-system python-build-system) + ,@(maybe-inputs 'propagated-inputs (list-ref inputs 0)) + ,@(maybe-inputs 'native-inputs (list-ref inputs 1)) + (home-page ,home-page) + (synopsis ,synopsis) + (description ,description) + (license ,(license->symbol license)))))))) (define (pypi->guix-package package-name) "Fetch the metadata for PACKAGE-NAME from pypi.python.org, and return the diff --git a/tests/pypi.scm b/tests/pypi.scm index 7f0ad23..cbf7066 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -68,6 +68,14 @@ baz > 13.37") \"baz (>13.37)\" ] } + ], + \"test_requires\": [ + { + \"requires\": [ + \"test-bar\", + \"test-baz (>42.42)\" + ] + } ] }") @@ -169,6 +177,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