From patchwork Mon Jan 16 20:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 46208 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CB07027BBED; Mon, 16 Jan 2023 20:38:15 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1F81F27BBE9 for ; Mon, 16 Jan 2023 20:38:14 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHWF2-0008Er-5Y; Mon, 16 Jan 2023 15:38:04 -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 ) id 1pHWF1-0008Eg-7P for guix-patches@gnu.org; Mon, 16 Jan 2023 15:38:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHWF0-0004Fm-NP for guix-patches@gnu.org; Mon, 16 Jan 2023 15:38:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHWF0-0000lC-J7 for guix-patches@gnu.org; Mon, 16 Jan 2023 15:38:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60868] [PATCH] build: pyproject-build-system: Use wrap-script instead of wrap-program. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Jan 2023 20:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60868 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60868@debbugs.gnu.org Cc: jgart , Lars-Dominik Braun , Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16739014582889 (code B ref -1); Mon, 16 Jan 2023 20:38:02 +0000 Received: (at submit) by debbugs.gnu.org; 16 Jan 2023 20:37:38 +0000 Received: from localhost ([127.0.0.1]:34944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) 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 ) 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 ) 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 ) 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 ; 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 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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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(-) base-commit: 6c2d3eb8aef45381961ad4e8cf0d03ccbf2bbd64 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)