build-system/pyproject: Export default-sanity-check.py.

There is currently no convenient way to inject our sanity-check.py
script in the inputs of a project that extends another build-system
with pyproject components.  Thus we usually don't run sanity-check for
such cases (it's only python build and install).

This patch improves a bit this issue by exposing our script.  Since it
doesn't change derivations, this doesn't lead to rebuilds and can be
merged in master.

* guix/build-system/pyproject.scm
  (sanity-check.py): Replace variable by...
  (default-sanity-check.py): Add exported procedure replacing and
  extending former sanity-check.py.
  (lower)[sanity-check.py]: Add and use argument.

Change-Id: I422d3d2d53b59548099d381feae9b956f5e2e07a
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2025-07-07 13:11:51 +02:00 committed by Sharlatan Hellseher
parent 6ab6ba14f8
commit 4557e8f581
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -32,6 +32,7 @@
#:use-module (srfi srfi-1)
#:export (%pyproject-build-system-modules
default-python
default-sanity-check.py
pyproject-build
pyproject-build-system))
@ -60,17 +61,20 @@
;; Using python-toolchain here might cause dependency cycles.
(module-ref python 'python-sans-pip-wrapper)))
(define sanity-check.py
(search-auxiliary-file "python/sanity-check.py"))
;; TODO: On the next iteration of python-team, migrate the sanity-check to
;; importlib_metadata instead of setuptools.
(define (default-sanity-check.py)
(local-file (search-auxiliary-file "python/sanity-check.py")))
(define* (lower name
#:key source inputs native-inputs outputs system target
(python (default-python))
(sanity-check.py (default-sanity-check.py))
#:allow-other-keys
#:rest arguments)
"Return a bag for NAME."
(define private-keywords
'(#:target #:python #:inputs #:native-inputs))
'(#:target #:python #:inputs #:native-inputs #:sanity-check.py))
(and (not target) ;XXX: no cross-compilation
(bag
@ -84,7 +88,7 @@
;; Keep the standard inputs of 'gnu-build-system'.
,@(standard-packages)))
(build-inputs `(("python" ,python)
("sanity-check.py" ,(local-file sanity-check.py))
("sanity-check.py" ,sanity-check.py)
,@native-inputs))
(outputs (append outputs '(wheel)))
(build pyproject-build)