[packages/meson] - added patch for vala crash when python is also installed (adjusted from git commit); release 2

qboosh qboosh at pld-linux.org
Sat Sep 9 18:23:00 CEST 2023


commit e1b098ebcba592ce8017f5f71d93abe3107ce09e
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sat Sep 9 17:55:18 2023 +0200

    - added patch for vala crash when python is also installed (adjusted from git commit); release 2

 meson-vala_with_python.patch | 156 +++++++++++++++++++++++++++++++++++++++++++
 meson.spec                   |   4 +-
 2 files changed, 159 insertions(+), 1 deletion(-)
---
diff --git a/meson.spec b/meson.spec
index 7e9450d..3eda56b 100644
--- a/meson.spec
+++ b/meson.spec
@@ -2,13 +2,14 @@ Summary:	High productivity build system
 Summary(pl.UTF-8):	System budowania o dużej produktywności
 Name:		meson
 Version:	1.2.1
-Release:	1
+Release:	2
 License:	Apache v2.0
 Group:		Development/Tools
 #Source0Download: https://github.com/mesonbuild/meson/releases/
 Source0:	https://github.com/mesonbuild/meson/releases/download/%{version}/%{name}-%{version}.tar.gz
 # Source0-md5:	e3cc846536189aacd7d01858a45ca9af
 Patch0:		%{name}-gtkdocdir.patch
+Patch1:		%{name}-vala_with_python.patch
 URL:		https://mesonbuild.com/
 BuildRequires:	ninja >= 1.8.2
 BuildRequires:	python3 >= 1:3.7
@@ -54,6 +55,7 @@ Mesona.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 %{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' \
 	meson.py
diff --git a/meson-vala_with_python.patch b/meson-vala_with_python.patch
new file mode 100644
index 0000000..fdeb948
--- /dev/null
+++ b/meson-vala_with_python.patch
@@ -0,0 +1,156 @@
+From b2654b2d43089c933e66ab1d3dfb547caecfea71 Mon Sep 17 00:00:00 2001
+From: Xavier Claessens <xavier.claessens at collabora.com>
+Date: Tue, 5 Sep 2023 07:49:18 -0400
+Subject: [PATCH] Fix crash when installing a vala library and python sources
+
+Installing python sources causes the python module to call
+create_install_data() before Ninja backends adds extra outputs to Vala
+targets.
+
+Target objects are supposed to be immutable, adding outputs that late is
+totally wrong. Add extra vala outputs immediately, but be careful
+because the main output is only added later in post_init(). Luckily
+the base class already puts a placeholder item in self.outputs for the
+main filename so we can just replace self.outputs[0] instead of
+replacing the whole list which would contain vala outputs at that stage.
+This is surprisingly what SharedLibrary was already doing.
+---
+ data/test.schema.json                            |  1 +
+ mesonbuild/backend/ninjabackend.py               |  4 ----
+ mesonbuild/build.py                              | 10 ++++++++--
+ run_project_tests.py                             |  5 ++++-
+ test cases/vala/7 shared library/lib/meson.build |  5 +++++
+ test cases/vala/7 shared library/lib/source.py   |  0
+ test cases/vala/7 shared library/test.json       |  4 +++-
+ 7 files changed, 21 insertions(+), 8 deletions(-)
+ create mode 100644 test cases/vala/7 shared library/lib/source.py
+
+--- meson-1.2.1/data/test.schema.json.orig	2023-09-09 09:50:21.534629717 +0200
++++ meson-1.2.1/data/test.schema.json	2023-09-09 09:51:23.307628398 +0200
+@@ -26,6 +26,7 @@
+               "exe",
+               "shared_lib",
+               "python_lib",
++              "python_bytecode",
+               "pdb",
+               "implib",
+               "py_implib",
+diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
+index 6c739ed0a1bf..491f2a63d834 100644
+--- a/mesonbuild/backend/ninjabackend.py
++++ b/mesonbuild/backend/ninjabackend.py
+@@ -1694,8 +1694,6 @@ def generate_vala_compile(self, target: build.BuildTarget) -> \
+             # Without this, it will write it inside c_out_dir
+             args += ['--vapi', os.path.join('..', target.vala_vapi)]
+             valac_outputs.append(vapiname)
+-            target.outputs += [target.vala_header, target.vala_vapi]
+-            target.install_tag += ['devel', 'devel']
+             # Install header and vapi to default locations if user requests this
+             if len(target.install_dir) > 1 and target.install_dir[1] is True:
+                 target.install_dir[1] = self.environment.get_includedir()
+@@ -1706,8 +1704,6 @@ def generate_vala_compile(self, target: build.BuildTarget) -> \
+                 girname = os.path.join(self.get_target_dir(target), target.vala_gir)
+                 args += ['--gir', os.path.join('..', target.vala_gir)]
+                 valac_outputs.append(girname)
+-                target.outputs.append(target.vala_gir)
+-                target.install_tag.append('devel')
+                 # Install GIR to default location if requested by user
+                 if len(target.install_dir) > 3 and target.install_dir[3] is True:
+                     target.install_dir[3] = os.path.join(self.environment.get_datadir(), 'gir-1.0')
+diff --git a/mesonbuild/build.py b/mesonbuild/build.py
+index edec75d9097e..09437037a89e 100644
+--- a/mesonbuild/build.py
++++ b/mesonbuild/build.py
+@@ -789,6 +789,12 @@ def post_init(self) -> None:
+             # relocation-model=pic is rustc's default and Meson does not
+             # currently have a way to disable PIC.
+             self.pic = True
++        if 'vala' in self.compilers and self.is_linkable_target():
++            self.outputs += [self.vala_header, self.vala_vapi]
++            self.install_tag += ['devel', 'devel']
++            if self.vala_gir:
++                self.outputs.append(self.vala_gir)
++                self.install_tag.append('devel')
+ 
+     def __repr__(self):
+         repr_str = "<{0} {1}: {2}>"
+@@ -1945,7 +1951,7 @@ def post_init(self) -> None:
+         self.filename = self.name
+         if self.suffix:
+             self.filename += '.' + self.suffix
+-        self.outputs = [self.filename]
++        self.outputs[0] = self.filename
+ 
+         # The import library this target will generate
+         self.import_filename = None
+@@ -2086,7 +2092,7 @@ def post_init(self) -> None:
+             else:
+                 self.suffix = 'a'
+         self.filename = self.prefix + self.name + '.' + self.suffix
+-        self.outputs = [self.filename]
++        self.outputs[0] = self.filename
+ 
+     def get_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
+         return {}
+--- meson-1.2.1/run_project_tests.py.orig	2023-06-28 16:48:20.000000000 +0200
++++ meson-1.2.1/run_project_tests.py	2023-09-09 09:52:47.253840289 +0200
+@@ -40,6 +40,7 @@ import time
+ import typing as T
+ import xml.etree.ElementTree as ET
+ import collections
++import importlib.util
+ 
+ from mesonbuild import build
+ from mesonbuild import environment
+@@ -167,7 +168,7 @@ class InstalledFile:
+             return None
+ 
+         # Handle the different types
+-        if self.typ in {'py_implib', 'python_lib', 'python_file'}:
++        if self.typ in {'py_implib', 'python_lib', 'python_file', 'python_bytecode'}:
+             val = p.as_posix()
+             val = val.replace('@PYTHON_PLATLIB@', python.platlib)
+             val = val.replace('@PYTHON_PURELIB@', python.purelib)
+@@ -184,6 +185,8 @@ class InstalledFile:
+                     return p.with_suffix('.dll.a')
+                 else:
+                     return None
++            if self.typ == 'python_bytecode':
++                return p.parent / importlib.util.cache_from_source(p.name)
+         elif self.typ in {'file', 'dir'}:
+             return p
+         elif self.typ == 'shared_lib':
+diff --git a/test cases/vala/7 shared library/lib/meson.build b/test cases/vala/7 shared library/lib/meson.build
+index edeeb96d19bb..bbd3862f1611 100644
+--- a/test cases/vala/7 shared library/lib/meson.build	
++++ b/test cases/vala/7 shared library/lib/meson.build	
+@@ -33,3 +33,8 @@ shared_library('installed_vala_onlyvapi', 'mylib.vala',
+   dependencies : valadeps,
+   install : true,
+   install_dir : [false, false, join_paths(get_option('datadir'), 'vala', 'vapi')])
++
++# Regression test: Vala libraries were broken when also installing python modules.
++# https://gitlab.gnome.org/GNOME/gitg/-/issues/412
++python = import('python').find_installation()
++python.install_sources('source.py')
+diff --git a/test cases/vala/7 shared library/lib/source.py b/test cases/vala/7 shared library/lib/source.py
+new file mode 100644
+index 000000000000..e69de29bb2d1
+--- a/test cases/vala/7 shared library/lib/source.py	
++++ b/test cases/vala/7 shared library/lib/source.py	
+@@ -1,0 +1,1 @@
++
+diff --git a/test cases/vala/7 shared library/test.json b/test cases/vala/7 shared library/test.json
+index eee3c3dca845..08bd707347c3 100644
+--- a/test cases/vala/7 shared library/test.json	
++++ b/test cases/vala/7 shared library/test.json	
+@@ -9,6 +9,8 @@
+     {"type": "file", "file": "usr/include/installed_vala_onlyh.h"},
+     {"type": "file", "file": "usr/share/vala/vapi/installed_vala_all.vapi"},
+     {"type": "file", "file": "usr/share/vala-1.0/vapi/installed_vala_all_nolib.vapi"},
+-    {"type": "file", "file": "usr/share/vala/vapi/installed_vala_onlyvapi.vapi"}
++    {"type": "file", "file": "usr/share/vala/vapi/installed_vala_onlyvapi.vapi"},
++    {"type": "python_file", "file": "usr/@PYTHON_PURELIB@/source.py"},
++    {"type": "python_bytecode", "file": "usr/@PYTHON_PURELIB@/source.py"}
+   ]
+ }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/meson.git/commitdiff/e1b098ebcba592ce8017f5f71d93abe3107ce09e



More information about the pld-cvs-commit mailing list