guix_mirror_bot pushed a commit to branch python-team
in repository guix.

commit d62d05eeca49d265604828f45945c31455ed28b4
Author: Nicolas Graves <[email protected]>
AuthorDate: Sun Sep 14 16:14:01 2025 +0200

    build-system: cargo: Migrate to `cargo metadata`.
    
    cargo read-manifest complains about its deprecation. The replacement
    is cargo metadata --no-deps --format-version 1, see
    https://github.com/rust-lang/cargo/issues/13629#cargo-read-manifest
    
    * guix/build/cargo-build-system.scm (manifest-targets): Refresh using
    `cargo metadata`.
    (has-executable-target?): Refresh accordingly.
    
    Change-Id: I4cd4881d37523a7ac1f70e68df457ceb9075c1c3
    Signed-off-by: Sharlatan Hellseher <[email protected]>
---
 guix/build/cargo-build-system.scm | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/guix/build/cargo-build-system.scm 
b/guix/build/cargo-build-system.scm
index 1c0531b41f..6b71c2cba4 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -37,6 +37,7 @@
   #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-43)
   #:use-module (json)
   #:export (%standard-phases
             cargo-build))
@@ -49,9 +50,12 @@
 
 (define (manifest-targets)
   "Extract all targets from the Cargo.toml manifest"
-  (let* ((port (open-input-pipe "cargo read-manifest"))
+  (let* ((command (string-join (list "cargo" "metadata" "--no-deps"
+                                      "--format-version" "1")))
+         (port (open-input-pipe command))
          (data (json->scm port))
-         (targets (or (assoc-ref data "targets") '())))
+         (packages (vector-ref (assoc-ref data "packages") 0))
+         (targets (or (assoc-ref packages "targets") '())))
     (close-port port)
     targets))
 
@@ -59,8 +63,8 @@
   "Check if the current cargo project declares any binary targets."
   (let* ((bin? (lambda (kind) (string=? kind "bin")))
          (get-kinds (lambda (dep) (assoc-ref dep "kind")))
-         (bin-dep? (lambda (dep) (find bin? (get-kinds dep)))))
-    (find bin-dep? (manifest-targets))))
+         (bin-dep? (lambda (dep) (vector-any bin? (get-kinds dep)))))
+    (vector-any bin-dep? (manifest-targets))))
 
 (define (cargo-package? dir)
   "Check if directory DIR contains a single package, or a Cargo workspace with

Reply via email to