guix_mirror_bot pushed a commit to branch python-team
in repository guix.
commit ef9e3bd050b1a1040157b88e03b8500574458c69
Author: Nicolas Graves <[email protected]>
AuthorDate: Sat Sep 13 07:02:47 2025 +0200
build-system: pyproject: Migrate to (json).
Since (json) is imported in Guix, we remove gradually the old (guix
build json) module.
* guix/build-system/pyproject.scm (%pyproject-build-system-modules):
Remove (guix build json).
(pyproject-guile-json): New procedure.
(pyproject-build): Add guile-json extension, fix configure-flags
argument.
* guix/build/pyproject-build-system.scm (build): Refresh procedure
replacing (guix build json) procedures with (json) ones.
Change-Id: I3aede51f971b27104340816b60cf53174a9bd332
Signed-off-by: Sharlatan Hellseher <[email protected]>
---
guix/build-system/pyproject.scm | 56 +++++++++++++++++++----------------
guix/build/pyproject-build-system.scm | 13 ++++----
2 files changed, 37 insertions(+), 32 deletions(-)
diff --git a/guix/build-system/pyproject.scm b/guix/build-system/pyproject.scm
index 03f3cb8544..24b3d4c40c 100644
--- a/guix/build-system/pyproject.scm
+++ b/guix/build-system/pyproject.scm
@@ -34,7 +34,8 @@
default-python
default-sanity-check.py
pyproject-build
- pyproject-build-system))
+ pyproject-build-system
+ pyproject-guile-json))
;; Commentary:
;;
@@ -46,7 +47,6 @@
(define %pyproject-build-system-modules
;; Build-side modules imported by default.
`((guix build pyproject-build-system)
- (guix build json)
(guix build toml)
,@%python-build-system-modules))
@@ -59,6 +59,10 @@
;; Using python-toolchain here might cause dependency cycles.
(@* (gnu packages python) python-sans-pip-wrapper))
+(define (pyproject-guile-json)
+ "Return the default guile-json package, resolved lazily."
+ (@* (gnu packages guile) guile-json-4))
+
;; TODO: On the next iteration of python-team, migrate the sanity-check to
;; importlib_metadata instead of setuptools.
(define (default-sanity-check.py)
@@ -95,7 +99,7 @@
(define* (pyproject-build name inputs
#:key source
(tests? #t)
- (configure-flags ''(@))
+ (configure-flags ''())
(backend-path #f)
(build-backend #f)
(test-backend #f)
@@ -105,6 +109,7 @@
(search-paths '())
(system (%current-system))
(guile #f)
+ (guile-json (pyproject-guile-json))
(imported-modules %pyproject-build-system-modules)
(modules '((guix build pyproject-build-system)
(guix build utils)))
@@ -112,29 +117,30 @@
disallowed-references)
"Build SOURCE using PYTHON, and with INPUTS."
(define build
- (with-imported-modules imported-modules
- #~(begin
- (use-modules #$@(sexp->gexp modules))
+ (with-extensions (list guile-json)
+ (with-imported-modules imported-modules
+ #~(begin
+ (use-modules #$@(sexp->gexp modules))
- #$(with-build-variables inputs outputs
- #~(pyproject-build
- #:name #$name
- #:source #+source
- #:configure-flags #$configure-flags
- #:system #$system
- #:backend-path #$backend-path
- #:build-backend #$build-backend
- #:test-backend #$test-backend
- #:test-flags #$test-flags
- #:tests? #$tests?
- #:phases #$(if (pair? phases)
- (sexp->gexp phases)
- phases)
- #:outputs %outputs
- #:search-paths '#$(sexp->gexp
- (map search-path-specification->sexp
- search-paths))
- #:inputs %build-inputs)))))
+ #$(with-build-variables inputs outputs
+ #~(pyproject-build
+ #:name #$name
+ #:source #+source
+ #:configure-flags #$configure-flags
+ #:system #$system
+ #:backend-path #$backend-path
+ #:build-backend #$build-backend
+ #:test-backend #$test-backend
+ #:test-flags #$test-flags
+ #:tests? #$tests?
+ #:phases #$(if (pair? phases)
+ (sexp->gexp phases)
+ phases)
+ #:outputs %outputs
+ #:search-paths '#$(sexp->gexp
+ (map search-path-specification->sexp
+ search-paths))
+ #:inputs %build-inputs))))))
(mlet %store-monad ((guile (package->derivation (or guile (default-guile))
diff --git a/guix/build/pyproject-build-system.scm
b/guix/build/pyproject-build-system.scm
index 28b9e96c9d..3868ddfda8 100644
--- a/guix/build/pyproject-build-system.scm
+++ b/guix/build/pyproject-build-system.scm
@@ -19,14 +19,14 @@
(define-module (guix build pyproject-build-system)
#:use-module ((guix build python-build-system) #:prefix python:)
- #:use-module ((guix build utils) #:hide (delete))
- #:use-module (guix build json)
+ #:use-module (guix build utils)
#:use-module (guix build toml)
#:use-module (ice-9 match)
#:use-module (ice-9 ftw)
#:use-module (ice-9 format)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 regex)
+ #:use-module (json)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
@@ -104,14 +104,13 @@
(auto-backend-path (recursive-assoc-ref
pyproject.toml
'("build-system" "backend-path")))
- (use-backend-path (call-with-output-string
- (cut write-json
- (or backend-path auto-backend-path '()) <>)))
+ (use-backend-path (scm->json-string
+ (list->vector
+ (or backend-path auto-backend-path '()))))
;; There is no easy way to get data from Guile into Python via
;; s-expressions, but we have JSON serialization already, which Python
;; also supports out-of-the-box.
- (config-settings (call-with-output-string
- (cut write-json configure-flags <>)))
+ (config-settings (scm->json-string configure-flags))
;; python-setuptools’ default backend supports setup.py *and*
;; pyproject.toml. Allow overriding this automatic detection via
;; build-backend.