GNU bug report logs

#60868 [PATCH] build: pyproject-build-system: Use wrap-script instead of wrap-program.

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Full log

Message #5 received at submit@debbugs.gnu.org (full text, mbox, reply):

Received: (at submit) by debbugs.gnu.org; 16 Jan 2023 20:37:38 +0000
From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 16 15:37:38 2023
Received: from localhost ([127.0.0.1]:34944 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1pHWEc-0000kX-2w
	for submit@debbugs.gnu.org; Mon, 16 Jan 2023 15:37:38 -0500
Received: from lists.gnu.org ([209.51.188.17]:35068)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@gmail.com>) id 1pHWEY-0000kN-Tc
 for submit@debbugs.gnu.org; Mon, 16 Jan 2023 15:37:36 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <maxim.cournoyer@gmail.com>)
 id 1pHWEX-0007k1-5m
 for guix-patches@gnu.org; Mon, 16 Jan 2023 15:37:33 -0500
Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <maxim.cournoyer@gmail.com>)
 id 1pHWES-0004B3-9x
 for guix-patches@gnu.org; Mon, 16 Jan 2023 15:37:30 -0500
Received: by mail-qt1-x82f.google.com with SMTP id j9so2830021qtv.4
 for <guix-patches@gnu.org>; Mon, 16 Jan 2023 12:37:27 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=tN3kCXvG1iYzSRadl4JQRWi6/dAIl4QrxTwLxEUiL6o=;
 b=qeO7asI4TGY3HyowVYt30TvO8pv3cc4DbME1crQYrGezz+7M8YduhhZQQwnReBaOzP
 1eDKyGZXFqBu04aLqKlA202Klgcv+xLVTCr+4IJI2t7u82t4t5S1FWFjKSC8m7cve0qC
 XKXcz/yYg/YA6McPlHpvlQ9LnSYRV5QlGA5XRx8hBE8oeZvwAhbe2JKSETnuqMKcXbFY
 K5aWty6I32oWTKOnw2XZqdvxRWvQd5s+Mfx5hkAYTx3RUzZBs31DEFFg3Vg8d/83dsLf
 XtVFYSFotetpALSxpN1Qr0AYRD6FyuNnXXJGBrMv4yVNrD1oidr4E1d0C83HYojNgxw/
 sMQg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=tN3kCXvG1iYzSRadl4JQRWi6/dAIl4QrxTwLxEUiL6o=;
 b=CxlebQH8ICL8FWk4FYL9T3nAWeNowQF2Ml5zx7BN0wU7zOeHHGVbVtfRYi+uqMpvQq
 NOVy7+EpSR9fNXFnsLcsDcs5F1NVl9gFK21d+PF2rN84cbwnx2TclXOAgefLH3hUW751
 Qy8vZtkdmZhyQ9Y3jBCWPYi302TFXtbzUo13JgjmO0kYJ0+n+ajIXH5IY/RRtlgy857h
 vsmviHJXSzFDkpRuMqr9r349bTQxHVfanRT0L4uLsuJ6yDnfX8t+nuXLOVgNsdo9rzax
 bQq1tPAi7GGigTQaKSOucwfZeDdVjpsDiojcMaoawhA51u7VIeXqqNb54NCuW9neb8gc
 nMtA==
X-Gm-Message-State: AFqh2kqKXfX997exPsyjT4bidB6Ul6C98XgV7COZzrixykdLWHiC0p5y
 KR6Ja365zzC4I1Tt3xB8FnAPrvm5PoHQHJ5Y
X-Google-Smtp-Source: AMrXdXtkH57DDGvbBziCyOMg0Nw49Qr43alg2H7VUO5PnD52aeq+3SJB3EqTKXxpxj4sWfXrNhtkjg==
X-Received: by 2002:a05:622a:22a6:b0:3b6:2b4b:5688 with SMTP id
 ay38-20020a05622a22a600b003b62b4b5688mr616211qtb.11.1673901447142; 
 Mon, 16 Jan 2023 12:37:27 -0800 (PST)
Received: from localhost.localdomain (dsl-10-130-209.b2b2c.ca. [72.10.130.209])
 by smtp.gmail.com with ESMTPSA id
 fd7-20020a05622a4d0700b003a5fb681ae7sm15126262qtb.3.2023.01.16.12.37.26
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 16 Jan 2023 12:37:26 -0800 (PST)
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: guix-patches@gnu.org
Subject: [PATCH] build: pyproject-build-system: Use wrap-script instead of
 wrap-program.
Date: Mon, 16 Jan 2023 15:37:11 -0500
Message-Id: <20230116203711.2214-1-maxim.cournoyer@gmail.com>
X-Mailer: git-send-email 2.38.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2607:f8b0:4864:20::82f;
 envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82f.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: jgart <jgart@dismail.de>, Lars-Dominik Braun <lars@6xq.net>,
 Maxim Cournoyer <maxim.cournoyer@gmail.com>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit@debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request@debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request@debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -2.3 (--)
* guix/build-system/pyproject.scm (default-guile): New procedure.
(lower) Add guile to the host-inputs of the bag.
* guix/build/pyproject-build-system.scm (wrap): Replace wrap-program with
wrap-script.  Rename bash-related nested variables/procedure with
guile-related ones.
---

 guix/build-system/pyproject.scm       |  9 +++++++-
 guix/build/pyproject-build-system.scm | 30 ++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/guix/build-system/pyproject.scm b/guix/build-system/pyproject.scm
index 74d739023f..8b5091c654 100644
--- a/guix/build-system/pyproject.scm
+++ b/guix/build-system/pyproject.scm
@@ -59,6 +59,12 @@ (define (default-python)
   (let ((python (resolve-interface '(gnu packages python))))
     (module-ref python 'python-toolchain)))
 
+(define (default-guile)
+  "Return the default Guile used to wrap Python scripts."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((guile (resolve-interface '(gnu packages guile))))
+    (module-ref guile 'guile-3.0)))
+
 (define sanity-check.py
   ;; TODO: Merge with sanity-check.py in the next rebuild cycle.
   (search-auxiliary-file "python/sanity-check-next.py"))
@@ -88,7 +94,8 @@ (define private-keywords
                           '())
                     ;; Keep the standard inputs of 'gnu-build-system'.
                     ,@(standard-packages)))
-    (host-inputs inputs)
+    (host-inputs (modify-inputs inputs
+                   (append (default-guile))))
     (target-inputs (if target
                        (standard-cross-packages target 'target)
                        '()))
diff --git a/guix/build/pyproject-build-system.scm b/guix/build/pyproject-build-system.scm
index e51b5cfc43..a66c1fb34a 100644
--- a/guix/build/pyproject-build-system.scm
+++ b/guix/build/pyproject-build-system.scm
@@ -445,9 +445,33 @@ (define* (add-install-to-pythonpath #:key native-inputs outputs
   "A phase that just wraps the 'add-installed-pythonpath' procedure."
   (add-installed-pythonpath native-inputs outputs))
 
-(define* (wrap #:key native-inputs outputs #:allow-other-keys #:rest args)
-  (apply (assoc-ref python:%standard-phases 'wrap)
-         (append args (list #:inputs native-inputs))))
+(define* (wrap #:key inputs outputs #:allow-other-keys)
+  (define (list-of-files dir)
+    (find-files dir (lambda (file stat)
+                      (and (eq? 'regular (stat:type stat))
+                           (not (wrapped-program? file))))))
+
+  (define bindirs
+    (append-map (match-lambda
+                  ((_ . dir)
+                   (list (string-append dir "/bin")
+                         (string-append dir "/sbin"))))
+                outputs))
+
+  ;; Do not require "guile" to be present in the package inputs
+  ;; even when there is nothing to wrap.
+  ;; Also, calculate (guile) only once to prevent some I/O.
+  (define %guile (delay (search-input-file inputs "bin/guile")))
+  (define (guile) (force %guile))
+
+  (let* ((var `("GUIX_PYTHONPATH" prefix
+                ,(search-path-as-string->list
+                  (or (getenv "GUIX_PYTHONPATH") "")))))
+    (for-each (lambda (dir)
+                (let ((files (list-of-files dir)))
+                  (for-each (cut wrap-script <> #:guile (guile) var)
+                            files)))
+              bindirs)))
 
 (define* (rename-pth-file #:key name native-inputs outputs #:allow-other-keys
                           #:rest args)

base-commit: 6c2d3eb8aef45381961ad4e8cf0d03ccbf2bbd64
-- 
2.38.1





Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Mon Dec 23 06:18:24 2024; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.