mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
import: pypi: Fix tests.
* guix/import/pypi.scm (unzip-command): Use invoke instead of system*. (read-wheel-metadata): Adapt accordingly. (guess-requirements-from-wheel): Improve readability. * tests/import/pypi.scm (parse-wheel-metadata): Add test (used to isolate the issue in another test). (pypi->guix-package, no wheel): Remove python-wheel from the result. (pypi->guix-package, no usable requirement file, no wheel.): Likewise. (pypi->guix-package, package name contains \"-\" followed by digits): Likewise. (package-latest-release): Likewise. (pypi->guix-package, no requires.txt, but wheel): Likewise. Also improve readability. Change-Id: I49e6ae549437a068acd85fa0f13471bc0af5a399 Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
committed by
Andreas Enge
parent
5cafd2bdb0
commit
483ee41756
@@ -303,8 +303,9 @@ not succeed."
|
|||||||
(mlet* %store-monad
|
(mlet* %store-monad
|
||||||
((drv (lower-object unzip))
|
((drv (lower-object unzip))
|
||||||
(built (built-derivations (list drv))))
|
(built (built-derivations (list drv))))
|
||||||
(return (string-append (derivation->output-path drv) "/bin/unzip"))))))))
|
(return (string-append (derivation->output-path drv)
|
||||||
(system* (string-append unzip-cmd (string-join args " " 'prefix)))))
|
"/bin/unzip"))))))))
|
||||||
|
(apply invoke unzip-cmd args)))
|
||||||
|
|
||||||
(define (parse-requires.txt requires.txt)
|
(define (parse-requires.txt requires.txt)
|
||||||
"Given REQUIRES.TXT, a path to a Setuptools requires.txt file, return a list
|
"Given REQUIRES.TXT, a path to a Setuptools requires.txt file, return a list
|
||||||
@@ -414,10 +415,9 @@ be extracted in a temporary directory."
|
|||||||
(metadata (string-append dirname "/METADATA")))
|
(metadata (string-append dirname "/METADATA")))
|
||||||
(call-with-temporary-directory
|
(call-with-temporary-directory
|
||||||
(lambda (dir)
|
(lambda (dir)
|
||||||
(if (zero?
|
(if (parameterize ((current-error-port (%make-void-port "rw+"))
|
||||||
(parameterize ((current-error-port (%make-void-port "rw+"))
|
(current-output-port (%make-void-port "rw+")))
|
||||||
(current-output-port (%make-void-port "rw+")))
|
(unzip-command wheel-archive "-d" dir metadata))
|
||||||
(unzip-command wheel-archive "-d" dir metadata)))
|
|
||||||
(parse-wheel-metadata (string-append dir "/" metadata))
|
(parse-wheel-metadata (string-append dir "/" metadata))
|
||||||
(begin
|
(begin
|
||||||
(warning
|
(warning
|
||||||
@@ -430,8 +430,7 @@ be extracted in a temporary directory."
|
|||||||
(call-with-temporary-output-file
|
(call-with-temporary-output-file
|
||||||
(lambda (temp port)
|
(lambda (temp port)
|
||||||
(if wheel-url
|
(if wheel-url
|
||||||
(and (url-fetch wheel-url temp)
|
(and=> (url-fetch wheel-url temp) read-wheel-metadata)
|
||||||
(read-wheel-metadata temp))
|
|
||||||
(list '() '())))))
|
(list '() '())))))
|
||||||
|
|
||||||
(define (guess-requirements-from-pyproject.toml dir)
|
(define (guess-requirements-from-pyproject.toml dir)
|
||||||
|
|||||||
@@ -270,6 +270,12 @@ files specified by SPECS. Return its file name."
|
|||||||
call-with-input-string)
|
call-with-input-string)
|
||||||
(parse-requires.txt test-requires.txt-beaker)))
|
(parse-requires.txt test-requires.txt-beaker)))
|
||||||
|
|
||||||
|
(test-equal "parse-wheel-metadata"
|
||||||
|
(list '("baz" "bar") '("pytest"))
|
||||||
|
(mock ((ice-9 ports) call-with-input-file
|
||||||
|
call-with-input-string)
|
||||||
|
(parse-wheel-metadata test-metadata)))
|
||||||
|
|
||||||
(test-equal "parse-wheel-metadata, with extras"
|
(test-equal "parse-wheel-metadata, with extras"
|
||||||
(list '("wrapt" "bar") '("tox" "bumpversion"))
|
(list '("wrapt" "bar") '("tox" "bumpversion"))
|
||||||
(mock ((ice-9 ports) call-with-input-file
|
(mock ((ice-9 ports) call-with-input-file
|
||||||
@@ -328,8 +334,7 @@ files specified by SPECS. Return its file name."
|
|||||||
(build-system pyproject-build-system)
|
(build-system pyproject-build-system)
|
||||||
(propagated-inputs (list python-bar python-foo))
|
(propagated-inputs (list python-bar python-foo))
|
||||||
(native-inputs (list python-pytest
|
(native-inputs (list python-pytest
|
||||||
python-setuptools
|
python-setuptools))
|
||||||
python-wheel))
|
|
||||||
(home-page "https://example.com")
|
(home-page "https://example.com")
|
||||||
(synopsis "summary")
|
(synopsis "summary")
|
||||||
(description "summary.")
|
(description "summary.")
|
||||||
@@ -431,8 +436,7 @@ files specified by SPECS. Return its file name."
|
|||||||
(with-pypi `(("/foo-1.0.0.tar.gz" 200 ,(file-dump tarball))
|
(with-pypi `(("/foo-1.0.0.tar.gz" 200 ,(file-dump tarball))
|
||||||
("/foo-1.0.0-py2.py3-none-any.whl"
|
("/foo-1.0.0-py2.py3-none-any.whl"
|
||||||
200 ,(file-dump wheel))
|
200 ,(file-dump wheel))
|
||||||
("/foo/json" 200 ,(lambda (port)
|
("/foo/json" 200 ,(cut display (foo-json) <>)))
|
||||||
(display (foo-json) port))))
|
|
||||||
;; Not clearing the memoization cache here would mean returning the value
|
;; Not clearing the memoization cache here would mean returning the value
|
||||||
;; computed in the previous test.
|
;; computed in the previous test.
|
||||||
(invalidate-memoization! pypi->guix-package)
|
(invalidate-memoization! pypi->guix-package)
|
||||||
@@ -448,8 +452,7 @@ files specified by SPECS. Return its file name."
|
|||||||
(build-system pyproject-build-system)
|
(build-system pyproject-build-system)
|
||||||
(propagated-inputs (list python-bar python-baz))
|
(propagated-inputs (list python-bar python-baz))
|
||||||
(native-inputs (list python-pytest
|
(native-inputs (list python-pytest
|
||||||
python-setuptools
|
python-setuptools))
|
||||||
python-wheel))
|
|
||||||
(home-page "https://example.com")
|
(home-page "https://example.com")
|
||||||
(synopsis "summary")
|
(synopsis "summary")
|
||||||
(description "summary.")
|
(description "summary.")
|
||||||
@@ -478,7 +481,7 @@ files specified by SPECS. Return its file name."
|
|||||||
(sha256
|
(sha256
|
||||||
(base32 ,(? string? hash)))))
|
(base32 ,(? string? hash)))))
|
||||||
(build-system pyproject-build-system)
|
(build-system pyproject-build-system)
|
||||||
(native-inputs (list python-setuptools python-wheel))
|
(native-inputs (list python-setuptools))
|
||||||
(home-page "https://example.com")
|
(home-page "https://example.com")
|
||||||
(synopsis "summary")
|
(synopsis "summary")
|
||||||
(description "summary.")
|
(description "summary.")
|
||||||
@@ -509,8 +512,7 @@ files specified by SPECS. Return its file name."
|
|||||||
(build-system pyproject-build-system)
|
(build-system pyproject-build-system)
|
||||||
(propagated-inputs (list python-bar python-foo))
|
(propagated-inputs (list python-bar python-foo))
|
||||||
(native-inputs (list python-pytest
|
(native-inputs (list python-pytest
|
||||||
python-setuptools
|
python-setuptools))
|
||||||
python-wheel))
|
|
||||||
(home-page "https://example.com")
|
(home-page "https://example.com")
|
||||||
(synopsis "summary")
|
(synopsis "summary")
|
||||||
(description "summary.")
|
(description "summary.")
|
||||||
@@ -537,10 +539,6 @@ files specified by SPECS. Return its file name."
|
|||||||
(upstream-input
|
(upstream-input
|
||||||
(name "setuptools")
|
(name "setuptools")
|
||||||
(downstream-name "python-setuptools")
|
(downstream-name "python-setuptools")
|
||||||
(type 'native))
|
|
||||||
(upstream-input
|
|
||||||
(name "wheel")
|
|
||||||
(downstream-name "python-wheel")
|
|
||||||
(type 'native))))
|
(type 'native))))
|
||||||
(let ((tarball (pypi-tarball
|
(let ((tarball (pypi-tarball
|
||||||
"foo-1.0.0"
|
"foo-1.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user