all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#60868] [PATCH] build: pyproject-build-system: Use wrap-script instead of wrap-program.
@ 2023-01-16 20:37 Maxim Cournoyer
  2023-01-17 15:52 ` Maxim Cournoyer
  2023-01-23 13:33 ` [bug#60868] [PATCH v2] " Maxim Cournoyer
  0 siblings, 2 replies; 4+ messages in thread
From: Maxim Cournoyer @ 2023-01-16 20:37 UTC (permalink / raw)
  To: 60868; +Cc: jgart, Lars-Dominik Braun, Maxim Cournoyer

* 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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-24  8:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-16 20:37 [bug#60868] [PATCH] build: pyproject-build-system: Use wrap-script instead of wrap-program Maxim Cournoyer
2023-01-17 15:52 ` Maxim Cournoyer
2023-01-23 13:33 ` [bug#60868] [PATCH v2] " Maxim Cournoyer
2023-01-24  8:42   ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.