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 #13 received at 60868@debbugs.gnu.org (full text, mbox, reply):

Received: (at 60868) by debbugs.gnu.org; 23 Jan 2023 13:34:06 +0000
From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 23 08:34:06 2023
Received: from localhost ([127.0.0.1]:53663 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1pJwxZ-0000rw-Nm
	for submit@debbugs.gnu.org; Mon, 23 Jan 2023 08:34:06 -0500
Received: from mail-yw1-f170.google.com ([209.85.128.170]:38546)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maxim.cournoyer@gmail.com>) id 1pJwxX-0000qY-Np
 for 60868@debbugs.gnu.org; Mon, 23 Jan 2023 08:34:04 -0500
Received: by mail-yw1-f170.google.com with SMTP id
 00721157ae682-4c131bede4bso171470867b3.5
 for <60868@debbugs.gnu.org>; Mon, 23 Jan 2023 05:34:03 -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=Zx91risw8UhmZa0NajYNxBtmDuGdN/pGwRfBcMdAQXE=;
 b=Ek49SjvX/bV/IEgI+0vmuMPTOruyzrIdriDk6egT2IAoZqkeZyHlgwAkvqfKyTwRsy
 YglF50fj36ELqiQmMeVZhD4PET2RfCqnyC3di27MLMZNIAXIy8U7VgFFNx34wJICLIvQ
 ayWAAY7s6fZOLgeowOsYQbpC/L/xaT0Jv98krawaIaTAw21415aCJqDladKHq1QmeoFL
 27iuI6NpEC8XOISE2lDICeexR15DSeiGRSX7z1RGXOhwBsLtExJTIOelB20eh8OKgLwL
 SCPIqsjJpj5yJu+QuENs/eEvII02ZLrgFSzazCe8NjXKUv1GsUyyJgPGvGNjvf6Rncmr
 V4/Q==
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=Zx91risw8UhmZa0NajYNxBtmDuGdN/pGwRfBcMdAQXE=;
 b=mZklqjyj2UEjgmBMZLK2ngbnr25EqxaQJnCVb2vZulrTrOeHd7kjSGuWl/dNfgC53j
 4PCZqKGfUFLh1GPOMMAMmEHUoeU8Fl6VlEcZ3nOTedTO8mGVXZ+hWPQmLv2JymBEvoln
 162SseGS3sR+ulPWcxjbM3fjXziPXTzp65nfK+u5FG35rYX7gRw9dm9gqi3XJh6uRrep
 pHfTfOxkfL/EmMJpLzokZ0kCLI2fMZmCGyJGxFnGnLARp6IkAL2Vywg7jRpxkIudCNJY
 ExFajm5jrbszmYlIZyHBTHHYKg8FCCDCIYFdK+sJXxRNuvC/a5NA4BoiqQsb15t8DRyF
 GXOQ==
X-Gm-Message-State: AFqh2ko5FMCQEy2ozcOrGlCoOGtaxXafaJASpSdAY30aWABOK2S5zClM
 y2zv7BL3sYx1wL/RZDWZ+NdSRhZMYw3dAgJ7
X-Google-Smtp-Source: AMrXdXs3qmJYBcvtfGJauyapzlw/d6Bn3+n4FPq4mOQEBc0R2c/0WoVYyXjkRwhrhexgjIuVm6M/WA==
X-Received: by 2002:a81:4f82:0:b0:4e0:cd27:b6b6 with SMTP id
 d124-20020a814f82000000b004e0cd27b6b6mr12628434ywb.33.1674480837991; 
 Mon, 23 Jan 2023 05:33:57 -0800 (PST)
Received: from localhost.localdomain ([2607:fad8:4:3::1001])
 by smtp.gmail.com with ESMTPSA id
 u24-20020a37ab18000000b006f9c2be0b4bsm15374927qke.135.2023.01.23.05.33.57
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 23 Jan 2023 05:33:57 -0800 (PST)
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 60868@debbugs.gnu.org
Subject: [PATCH v2] build: pyproject-build-system: Use wrap-script instead of
 wrap-program.
Date: Mon, 23 Jan 2023 08:33:54 -0500
Message-Id: <20230123133354.1345-1-maxim.cournoyer@gmail.com>
X-Mailer: git-send-email 2.39.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60868
Cc: jgart <jgart@dismail.de>, ludo@gnu.org, 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: -1.0 (-)
* 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.

---

Changes in v2:
- Rebase

 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: 67458b9793d69c7d10c7d885edd5d1ce5a2e9648
-- 
2.39.1





Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Mon Dec 23 06:45:17 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.