diff mbox series

[bug#51948] Meson needs proper wrapping

Message ID 87r1bda6ff.fsf@planete-kraus.eu
State Accepted
Headers show
Series [bug#51948] Meson needs proper wrapping | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Vivien Kraus Nov. 18, 2021, 2:23 p.m. UTC
Dear guix,

Meson needs to be wrapped, but the wrapping must not execute a new
process, if I understand correctly. I could use wrap-script, but I think
it’s more pythonic to set the path through sys.path rather than setting
an environment variable.

Now, this will create a world rebuild… What do you think?

Vivien

Comments

Ludovic Courtès Nov. 19, 2021, 1:12 p.m. UTC | #1
Hi!

Vivien Kraus <vivien@planete-kraus.eu> skribis:

> Meson needs to be wrapped, but the wrapping must not execute a new
> process, if I understand correctly. I could use wrap-script, but I think
> it’s more pythonic to set the path through sys.path rather than setting
> an environment variable.

Isn’t that what ‘wrap-script’ does?

> Now, this will create a world rebuild… What do you think?

Not good!  :-)

This Meson issue is not a regression compared to master, is it?

How about providing a user-facing ‘meson’ package that incorporates this
fix, while keeping the other ‘meson’ packages unchanged, to avoid
rebuilding too much?  This can be achieved by marking the other packages
as hidden.

> From 08845844e8e1a18232bf54f9f3f0b71d5e0c71ef Mon Sep 17 00:00:00 2001
> From: Vivien Kraus <vivien@planete-kraus.eu>
> Date: Thu, 18 Nov 2021 15:17:52 +0100
> Subject: [PATCH] gnu: meson: Extend the python path in the installed program.
>
> * gnu/packages/build-tools.scm (meson) [phase wrap]: Wrap the python path as
> python code.
> ---
>  gnu/packages/build-tools.scm | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
> index 849101c2a4..ef5aa4bd35 100644
> --- a/gnu/packages/build-tools.scm
> +++ b/gnu/packages/build-tools.scm
> @@ -283,7 +283,21 @@ (define-public meson
>         #:phases (modify-phases %standard-phases
>                    ;; Meson calls the various executables in out/bin through the
>                    ;; Python interpreter, so we cannot use the shell wrapper.
> -                  (delete 'wrap))))
> +                  (replace 'wrap
> +                    (lambda* (#:key outputs #:allow-other-keys)
> +                      (let ((path (string-split (getenv "GUIX_PYTHONPATH") #\:)))
> +                        (substitute* (string-append (assoc-ref outputs "out") "/bin/meson")

Could you check ‘guix gc --references meson’ to make sure it does not
capture too much?  (GUIX_PYTHONPATH might contain references to
build-time dependencies.)

I suppose GUIX_PYTHONPATH contains the package’s “out”, right?

Thanks!

Ludo’.
diff mbox series

Patch

From 08845844e8e1a18232bf54f9f3f0b71d5e0c71ef Mon Sep 17 00:00:00 2001
From: Vivien Kraus <vivien@planete-kraus.eu>
Date: Thu, 18 Nov 2021 15:17:52 +0100
Subject: [PATCH] gnu: meson: Extend the python path in the installed program.

* gnu/packages/build-tools.scm (meson) [phase wrap]: Wrap the python path as
python code.
---
 gnu/packages/build-tools.scm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 849101c2a4..ef5aa4bd35 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -283,7 +283,21 @@  (define-public meson
        #:phases (modify-phases %standard-phases
                   ;; Meson calls the various executables in out/bin through the
                   ;; Python interpreter, so we cannot use the shell wrapper.
-                  (delete 'wrap))))
+                  (replace 'wrap
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((path (string-split (getenv "GUIX_PYTHONPATH") #\:)))
+                        (substitute* (string-append (assoc-ref outputs "out") "/bin/meson")
+                          (("# EASY-INSTALL-ENTRY-SCRIPT")
+                           (format #f "\
+import sys
+~a
+# EASY-INSTALL-ENTRY-SCRIPT"
+                                   (string-join
+                                    (map (lambda (path)
+                                           (format #f "sys.path.insert(0, '~a')"
+                                                   path))
+                                         (reverse path))
+                                    "\n"))))))))))
     (inputs `(("ninja" ,ninja)))
     (propagated-inputs `(("python" ,python)))
     (home-page "https://mesonbuild.com/")
-- 
2.34.0