1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-01 14:55:55 +02:00

import: pypi: Use guix-hash-url and download-to-store.

* guix/import/pypi.scm (make-pypi-sexp): Use guix-hash-url and
download-to-store instead of http-fetch.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Nicolas Graves
2025-09-16 18:25:15 +02:00
committed by Ludovic Courtès
parent 1e37976756
commit 2c5b7a3b63
+6 -9
View File
@@ -40,13 +40,12 @@
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:use-module (srfi srfi-71)
#:autoload (gcrypt hash) (port-sha256)
#:autoload (guix base16) (base16-string->bytevector)
#:autoload (guix base32) (bytevector->nix-base32-string)
#:autoload (guix derivations) (built-derivations
derivation->output-path)
#:autoload (guix gexp) (lower-object)
#:autoload (guix http-client) (http-fetch)
#:use-module ((guix download) #:select (download-to-store))
#:use-module (guix utils)
#:use-module (guix memoization)
#:use-module (guix monads)
@@ -599,6 +598,9 @@ VERSION."
distribution-url))
(sha256 (and=> (source-release pypi-package version)
distribution-sha256))
(sha256 (or (and=> sha256 bytevector->nix-base32-string)
(guix-hash-url (with-store store
(download-to-store store source-url)))))
(source (pypi-package->upstream-source pypi-package version)))
(values
`(package
@@ -616,13 +618,8 @@ VERSION."
,@(if (string-suffix? ".zip" source-url)
'(".zip")
'())))
(sha256 (base32
,(and=> (or sha256
(let* ((port (http-fetch source-url))
(hash (port-sha256 port)))
(close-port port)
hash))
bytevector->nix-base32-string)))))
(sha256
(base32 ,sha256))))
,@(maybe-upstream-name name)
(build-system pyproject-build-system)
,@(maybe-inputs (upstream-source-propagated-inputs source)