[meta-python][PATCH v2 1/4] python_mesonpy.bbclass: New class


Zoltan Boszormenyi
 

Some python modules (e.g. SciPy, scikit-image) use meson-python
(a.k.a. mesonpy) in pyproject.toml:

[build-system]
build-backend = 'mesonpy'

This class, together with python3-meson-python and its dependencies
will allow building such modules.

Signed-off-by: Zoltán Böszörményi <zboszor@...>
---
meta-python/classes/python_mesonpy.bbclass | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 meta-python/classes/python_mesonpy.bbclass

diff --git a/meta-python/classes/python_mesonpy.bbclass b/meta-python/classes/python_mesonpy.bbclass
new file mode 100644
index 000000000..f4c4a217a
--- /dev/null
+++ b/meta-python/classes/python_mesonpy.bbclass
@@ -0,0 +1,17 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit setuptools3-base python3targetconfig python_pep517 meson-common
+
+DEPENDS += "python3-wheel-native python3-meson-python-native"
+
+PEP517_BUILD_OPTS = '--config-setting=setup-args="${MESONOPTS} ${MESON_SOURCEPATH} ${B} ${MESON_CROSS_FILE} ${EXTRA_OEMESON}"'
+
+export MESONPY_BUILD = "${B}"
+
+# Python pyx -> c -> so build leaves absolute build paths in the code
+INSANE_SKIP:${PN} += "buildpaths"
+INSANE_SKIP:${PN}-src += "buildpaths"
--
2.39.2


Ross Burton
 

On 17 Mar 2023, at 07:25, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@...> wrote:
+inherit setuptools3-base python3targetconfig python_pep517 meson-common
I still don’t see why you need to split the meson class up.

Ross


Zoltan Boszormenyi
 

2023. 03. 20. 15:46 keltezéssel, Ross Burton írta:
On 17 Mar 2023, at 07:25, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@...> wrote:
+inherit setuptools3-base python3targetconfig python_pep517 meson-common
I still don’t see why you need to split the meson class up.
See the other thread. For some reason, meson always wins
regardless of the inheritance order, so do_configure has
meson_do_configure instead of pep517_do_configure, etc.


Ross


Ross Burton
 

On 20 Mar 2023, at 15:01, Böszörményi Zoltán <zboszor@...> wrote:

2023. 03. 20. 15:46 keltezéssel, Ross Burton írta:
On 17 Mar 2023, at 07:25, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@...> wrote:
+inherit setuptools3-base python3targetconfig python_pep517 meson-common
I still don’t see why you need to split the meson class up.
See the other thread. For some reason, meson always wins
regardless of the inheritance order, so do_configure has
meson_do_configure instead of pep517_do_configure, etc.
Add a new do_configure to your class which simply calls the right one.

Ross


Zoltan Boszormenyi
 

2023. 03. 20. 17:26 keltezéssel, Ross Burton írta:
On 20 Mar 2023, at 15:01, Böszörményi Zoltán <zboszor@...> wrote:
2023. 03. 20. 15:46 keltezéssel, Ross Burton írta:
On 17 Mar 2023, at 07:25, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@...> wrote:
+inherit setuptools3-base python3targetconfig python_pep517 meson-common
I still don’t see why you need to split the meson class up.
See the other thread. For some reason, meson always wins
regardless of the inheritance order, so do_configure has
meson_do_configure instead of pep517_do_configure, etc.
Add a new do_configure to your class which simply calls the right one.
It still doesn't work. meson_do_qa_configure fails with this:

ERROR: python3-meson-python-native-0.13.0.pre0-r0 do_configure: Error executing a python function in exec_func_python() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:meson_do_qa_configure(d)
     0003:
File: '/data2/dtd-yocto-4.2/conf/../layers/openembedded-core/meta/classes-recipe/meson.bbclass', lineno: 163, function: meson_do_qa_configure
     0159:
     0160:python meson_do_qa_configure() {
     0161:    import re
     0162:    warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE)
 *** 0163:    with open(d.expand("${B}/meson-logs/meson-log.txt")) as logfile:
     0164:        log = logfile.read()
     0165:    for (prop, value) in warn_re.findall(log):
     0166:        bb.warn("Meson cross property %s used without explicit assignment, defaulting to %s" % (prop, value))
     0167:}
Exception: FileNotFoundError: [Errno 2] No such file or directory: '/data2/dtd-yocto-4.2/tmp-sicom-glibc/work/x86_64-linux/python3-meson-python-native/0.13.0.pre0-r0/build/meson-logs/meson-log.txt'

ERROR: Logfile of failure stored in: /data2/dtd-yocto-4.2/tmp-sicom-glibc/work/x86_64-linux/python3-meson-python-native/0.13.0.pre0-r0/temp/log.do_configure.3235105
ERROR: Task (virtual:native:/data2/dtd-yocto-4.2/conf/../layers/meta-sicom/recipes-support/python3/python3-meson-python_0.13.0.pre0.bb:do_configure) failed with exit code '1'

Naturally, as running meson's configure stage went from
do_configure to do_compile indirectly via "nativepython3 -m build ..."

Sorry, there seems to be no way around it but splitting out the
environment setup from meson.bbclass into meson-common class.
If you don't like the "-common" naming, I can rename it to
meson-env.bbclass or something like that.

I will still rework python3-meson-python to not require
the dummy patchelf python module and review other
comments and make necessary changes.

Thanks.


Zoltan Boszormenyi
 

2023. 03. 22. 9:18 keltezéssel, Zoltan Boszormenyi via lists.openembedded.org írta:
2023. 03. 20. 17:26 keltezéssel, Ross Burton írta:
On 20 Mar 2023, at 15:01, Böszörményi Zoltán <zboszor@...> wrote:
2023. 03. 20. 15:46 keltezéssel, Ross Burton írta:
On 17 Mar 2023, at 07:25, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@...> wrote:
+inherit setuptools3-base python3targetconfig python_pep517 meson-common
I still don’t see why you need to split the meson class up.
See the other thread. For some reason, meson always wins
regardless of the inheritance order, so do_configure has
meson_do_configure instead of pep517_do_configure, etc.
Add a new do_configure to your class which simply calls the right one.
It still doesn't work. meson_do_qa_configure fails with this: [...]
This construct also doesn't work
===================================
inherit meson
do_configure[postfuncs]:remove = "meson_do_qa_configure"
===================================

It results in an "unparsed line" error. So, I have to re-iterate this:

Sorry, there seems to be no way around it but splitting out the
environment setup from meson.bbclass into meson-common class.
If you don't like the "-common" naming, I can rename it to
meson-env.bbclass or something like that.

I will still rework python3-meson-python to not require
the dummy patchelf python module and review other
comments and make necessary changes.