From 2c5b7a3b63f14b78a4eb21680ca5a3e01ad4cc0b Mon Sep 17 00:00:00 2001 From: Nicolas Graves Date: Tue, 16 Sep 2025 18:25:15 +0200 Subject: [PATCH] import: pypi: Use guix-hash-url and download-to-store. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- guix/import/pypi.scm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index 80d184a80c2ede4ce6247b965ab74a98e0aea814..326e4453b20b071458b6c00a5ce835cc920b0591 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -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)