build-system/pyproject: Handle wheel not found exception.

The current error is very uninformative, use a proper exception to
give more information when this happens:
`In procedure map: Wrong type argument: #f`

After this patch:
`In procedure raise-exception:
ERROR:
  1. &no-wheels-found`

* guix/build/pyproject-build-system.scm (&no-wheels-found): Add exception.
(install): Handle exception.

Change-Id: Ie72d3b50dfededb2d598162672cdb4321c42b632
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2025-07-06 16:13:54 +02:00 committed by Sharlatan Hellseher
parent 75614b830b
commit 9b37d265a8
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -87,6 +87,9 @@
;; Raised, when no wheel has been built by the build system.
(define-condition-type &no-wheels-built &python-build-error no-wheels-built?)
;; Raised, when no installation candidate wheel has been found.
(define-condition-type &no-wheels-found &python-build-error no-wheels-found?)
(define* (build #:key outputs build-backend backend-path configure-flags #:allow-other-keys)
"Build a given Python package."
@ -251,10 +254,15 @@ builder.build_wheel(sys.argv[3], config_settings=config_settings)"
(let* ((wheel-output (assoc-ref outputs "wheel"))
(wheel-dir (if wheel-output wheel-output "dist"))
(wheels (map (cut string-append wheel-dir "/" <>)
(scandir wheel-dir
(cut string-suffix? ".whl" <>)))))
(wheels-found (or (scandir wheel-dir
(cut string-suffix? ".whl" <>))
'()))
(wheels (map (cut string-append wheel-dir "/" <>) wheels-found)))
(cond
;; This can happen if the 'build phase has been changed or when using
;; the install phase using an alternative build-system.
((null? wheels-found)
(raise (condition (&no-wheels-found))))
((> (length wheels) 1)
;; This code does not support multiple wheels yet, because their
;; outputs would have to be merged properly.