bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25235: [PATCH v2 1/1] build-system/pyproject: Do not wrap native-inp


From: Maxim Cournoyer
Subject: bug#25235: [PATCH v2 1/1] build-system/pyproject: Do not wrap native-inputs.
Date: Wed, 18 Jan 2023 09:00:35 -0500

Fixes <https://issues.guix.gnu.org/25235>.

* guix/build/pyproject-build-system.scm (wrap) [native-inputs]: New argument.
Filter out native inputs from the values in GUIX_PYTHONPATH.

---

Changes in v2:
- Add missing copyright line
- Rework wrap phase to avoid removing inputs found in both native-inputs and 
inputs
- Enclose wrap computations in an 'unless' form and streamline

 guix/build/pyproject-build-system.scm | 39 ++++++++++++++++-----------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/guix/build/pyproject-build-system.scm 
b/guix/build/pyproject-build-system.scm
index a66c1fb34a..9da86bfc54 100644
--- a/guix/build/pyproject-build-system.scm
+++ b/guix/build/pyproject-build-system.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
 ;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -445,7 +446,7 @@ (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 inputs outputs #:allow-other-keys)
+(define* (wrap #:key native-inputs inputs outputs #:allow-other-keys)
   (define (list-of-files dir)
     (find-files dir (lambda (file stat)
                       (and (eq? 'regular (stat:type stat))
@@ -458,20 +459,28 @@ (define bindirs
                          (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)))
+  (unless (null? bindirs)
+    (let* ((guile (search-input-file inputs "bin/guile"))
+           (native-input-dirs (match native-inputs
+                                (((_ . dir) ...)
+                                 dir)))
+           (input-dirs (match inputs
+                         (((_ . dir) ...)
+                          dir)))
+           (build-inputs (lset-difference string=? native-input-dirs
+                                          input-dirs))
+           ;; A build input is an input listed in native-inputs and NOT in
+           ;; inputs.
+           (build-input? (lambda (x)
+                           (any (cut string-prefix? <> x) build-inputs)))
+           (var `("GUIX_PYTHONPATH" prefix
+                  ,(remove build-input? (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)
-- 
2.39.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]