* [bug#51948] [PATCH] Meson needs proper wrapping
@ 2021-11-18 14:23 Vivien Kraus via Guix-patches via
[not found] ` <handler.51948.B.16372454395205.ack@debbugs.gnu.org>
2021-11-19 13:12 ` [bug#51948] [PATCH] Meson needs proper wrapping Ludovic Courtès
0 siblings, 2 replies; 7+ messages in thread
From: Vivien Kraus via Guix-patches via @ 2021-11-18 14:23 UTC (permalink / raw)
To: 51948
[-- Attachment #1.1: Type: text/plain, Size: 334 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Properly wrap meson --]
[-- Type: text/x-patch, Size: 1852 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#51948] Acknowledgement ([PATCH] Meson needs proper wrapping)
[not found] ` <handler.51948.B.16372454395205.ack@debbugs.gnu.org>
@ 2021-11-18 16:00 ` Vivien Kraus via Guix-patches via
0 siblings, 0 replies; 7+ messages in thread
From: Vivien Kraus via Guix-patches via @ 2021-11-18 16:00 UTC (permalink / raw)
To: 51948
[-- Attachment #1.1: Type: text/plain, Size: 87 bytes --]
If I put the code in a new variable, we avoid a world rebuild, is it
better?
Vivien
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: New meson-wrapped package --]
[-- Type: text/x-patch, Size: 2089 bytes --]
From f25082c0a695734aaada2d286ef1770de5f99c2b 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-wrapped): New variable.
---
gnu/packages/build-tools.scm | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 849101c2a4..646e28e0c6 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -297,6 +297,31 @@ (define-public meson
resembles Python.")
(license license:asl2.0)))
+(define-public meson-wrapped
+ (package/inherit meson
+ (arguments
+ `(;; FIXME: Tests require many additional inputs and patching many
+ ;; hard-coded file system locations in "run_unittests.py".
+ #:tests? #f
+ #:phases (modify-phases %standard-phases
+ ;; Meson calls the various executables in out/bin through the
+ ;; Python interpreter, so we cannot use the shell wrapper.
+ (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"))))))))))))
+
;;; This older Meson variant is kept for now for gtkmm and others that may
;;; have problems with 0.60.
(define-public meson-0.59
--
2.34.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#51948] [PATCH] Meson needs proper wrapping
2021-11-18 14:23 [bug#51948] [PATCH] Meson needs proper wrapping Vivien Kraus via Guix-patches via
[not found] ` <handler.51948.B.16372454395205.ack@debbugs.gnu.org>
@ 2021-11-19 13:12 ` Ludovic Courtès
2021-11-19 13:20 ` Vivien Kraus via Guix-patches via
1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2021-11-19 13:12 UTC (permalink / raw)
To: Vivien Kraus; +Cc: 51948
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’.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#51948] [PATCH] Meson needs proper wrapping
2021-11-19 13:12 ` [bug#51948] [PATCH] Meson needs proper wrapping Ludovic Courtès
@ 2021-11-19 13:20 ` Vivien Kraus via Guix-patches via
2021-11-19 22:17 ` Ludovic Courtès
0 siblings, 1 reply; 7+ messages in thread
From: Vivien Kraus via Guix-patches via @ 2021-11-19 13:20 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 51948
[-- Attachment #1.1: Type: text/plain, Size: 1371 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> 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?
I think wrap-script converts the python script to a guile script that
happens to be the same file as the python script. I realize it won’t
even insert python code in the final program, so the wrapping code won’t
be executed when the python module is loaded by the python interpreter.
> 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.
I pushed an update that does precisely that. Is the name "meson-wrapped"
OK? Also, how can I influence guix to rather install the wrapped version
when the user invokes "guix install 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 see, the only thing to wrap is just the "out" output in fact.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-meson-Extend-the-python-path-in-the-installed-pr.patch --]
[-- Type: text/x-patch, Size: 1933 bytes --]
From dcb7114ada82da073adbbfbeef929a9daa558ccb 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-wrapped): New variable.
---
gnu/packages/build-tools.scm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 849101c2a4..f323b6a388 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -297,6 +297,28 @@ (define-public meson
resembles Python.")
(license license:asl2.0)))
+(define-public meson-wrapped
+ (package/inherit meson
+ (arguments
+ `(;; FIXME: Tests require many additional inputs and patching many
+ ;; hard-coded file system locations in "run_unittests.py".
+ #:tests? #f
+ #:phases (modify-phases %standard-phases
+ ;; Meson calls the various executables in out/bin through the
+ ;; Python interpreter, so we cannot use the shell wrapper.
+ (replace 'wrap
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let ((python-version
+ (python-version (assoc-ref inputs "python")))
+ (output (assoc-ref outputs "out")))
+ (substitute* (string-append output "/bin/meson")
+ (("# EASY-INSTALL-ENTRY-SCRIPT")
+ (format #f "\
+import sys
+sys.path.insert(0, '~a/lib/python~a/site-packages')
+# EASY-INSTALL-ENTRY-SCRIPT"
+ output python-version)))))))))))
+
;;; This older Meson variant is kept for now for gtkmm and others that may
;;; have problems with 0.60.
(define-public meson-0.59
--
2.34.0
[-- Attachment #1.3: Type: text/plain, Size: 8 bytes --]
Vivien
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [bug#51948] [PATCH] Meson needs proper wrapping
2021-11-19 13:20 ` Vivien Kraus via Guix-patches via
@ 2021-11-19 22:17 ` Ludovic Courtès
2021-11-19 22:34 ` Vivien Kraus via Guix-patches via
0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2021-11-19 22:17 UTC (permalink / raw)
To: Vivien Kraus; +Cc: 51948
Hi,
Vivien Kraus <vivien@planete-kraus.eu> skribis:
>> 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.
> I pushed an update that does precisely that. Is the name "meson-wrapped"
> OK? Also, how can I influence guix to rather install the wrapped version
> when the user invokes "guix install meson"?
I you just add another meson@0.60 package like this patch does, the UI
will complain that “meson@0.60” is ambiguous, that there are two of them.
To work around it, I’d mark the unwrapped meson@0.60 as hidden (using
the ‘properties’ field) while keeping the other one visible.
That way “guix install meson” will install the wrapped one.
Does that make sense?
TIA,
Ludo’.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug#51948] [PATCH] Meson needs proper wrapping
2021-11-19 22:17 ` Ludovic Courtès
@ 2021-11-19 22:34 ` Vivien Kraus via Guix-patches via
2021-11-22 21:44 ` bug#51948: [PATCH] [core-updates-frozen] Wrap meson with python code Ludovic Courtès
0 siblings, 1 reply; 7+ messages in thread
From: Vivien Kraus via Guix-patches via @ 2021-11-19 22:34 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 51948
[-- Attachment #1.1: Type: text/plain, Size: 830 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
>> I pushed an update that does precisely that. Is the name "meson-wrapped"
>> OK? Also, how can I influence guix to rather install the wrapped version
>> when the user invokes "guix install meson"?
>
> I you just add another meson@0.60 package like this patch does, the UI
> will complain that “meson@0.60” is ambiguous, that there are two of them.
>
> To work around it, I’d mark the unwrapped meson@0.60 as hidden (using
> the ‘properties’ field) while keeping the other one visible.
>
> That way “guix install meson” will install the wrapped one.
I think that’s good: I build it with guix shell meson or guix build
meson, and I can run its absolute file name in a guix shell --pure
gcc. However, it does not seem to cause a world rebuild.
Vivien
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Meson is now hidden, the wrapped version is not --]
[-- Type: text/x-patch, Size: 2327 bytes --]
From 3f77d8d5c652725411a21434443cbf2a2d135575 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-wrapped): New variable.
---
gnu/packages/build-tools.scm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 849101c2a4..6a8a9c6f66 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -287,6 +287,7 @@ (define-public meson
(inputs `(("ninja" ,ninja)))
(propagated-inputs `(("python" ,python)))
(home-page "https://mesonbuild.com/")
+ (properties '((hidden? . #t)))
(synopsis "Build system designed to be fast and user-friendly")
(description
"The Meson build system is focused on user-friendliness and speed.
@@ -297,6 +298,29 @@ (define-public meson
resembles Python.")
(license license:asl2.0)))
+(define-public meson-wrapped
+ (package/inherit meson
+ (arguments
+ `(;; FIXME: Tests require many additional inputs and patching many
+ ;; hard-coded file system locations in "run_unittests.py".
+ #:tests? #f
+ #:phases (modify-phases %standard-phases
+ ;; Meson calls the various executables in out/bin through the
+ ;; Python interpreter, so we cannot use the shell wrapper.
+ (replace 'wrap
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let ((python-version
+ (python-version (assoc-ref inputs "python")))
+ (output (assoc-ref outputs "out")))
+ (substitute* (string-append output "/bin/meson")
+ (("# EASY-INSTALL-ENTRY-SCRIPT")
+ (format #f "\
+import sys
+sys.path.insert(0, '~a/lib/python~a/site-packages')
+# EASY-INSTALL-ENTRY-SCRIPT"
+ output python-version)))))))))
+ (properties '())))
+
;;; This older Meson variant is kept for now for gtkmm and others that may
;;; have problems with 0.60.
(define-public meson-0.59
--
2.34.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#51948: [PATCH] [core-updates-frozen] Wrap meson with python code
2021-11-19 22:34 ` Vivien Kraus via Guix-patches via
@ 2021-11-22 21:44 ` Ludovic Courtès
0 siblings, 0 replies; 7+ messages in thread
From: Ludovic Courtès @ 2021-11-22 21:44 UTC (permalink / raw)
To: Vivien Kraus; +Cc: 51948-done
Hi,
Vivien Kraus <vivien@planete-kraus.eu> skribis:
> From 3f77d8d5c652725411a21434443cbf2a2d135575 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-wrapped): New variable.
Applied, thanks!
As discussed on IRC, I followed up with a patch that moves Python from
‘propagated-inputs’ (!) to ‘inputs’ in ‘meson-wrapped’. Most likely
Python was propagated just for the sake of setting GUIX_PYTHONPATH, but
it’s bad style as it forces it into user profiles.
Ludo’.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-22 21:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-18 14:23 [bug#51948] [PATCH] Meson needs proper wrapping Vivien Kraus via Guix-patches via
[not found] ` <handler.51948.B.16372454395205.ack@debbugs.gnu.org>
2021-11-18 16:00 ` [bug#51948] Acknowledgement ([PATCH] Meson needs proper wrapping) Vivien Kraus via Guix-patches via
2021-11-19 13:12 ` [bug#51948] [PATCH] Meson needs proper wrapping Ludovic Courtès
2021-11-19 13:20 ` Vivien Kraus via Guix-patches via
2021-11-19 22:17 ` Ludovic Courtès
2021-11-19 22:34 ` Vivien Kraus via Guix-patches via
2021-11-22 21:44 ` bug#51948: [PATCH] [core-updates-frozen] Wrap meson with python code Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).