Skip to contentSkip to conversation

python3-meson-python: New recipe

PATCH Superseded Zoltán Böszörményi 2 participants 9 messages Jun 7, 2023 – Jun 8, 2023 1 message not in the archive Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 python3-meson-python: New recipe

This python module adds support for a new PEP517 build backend used by recent versions of scikit-image, scipy and others.

---
 .../python/python3-meson-python_0.13.1.bb     | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-meson-python_0.13.1.bb
meta-python/recipes-devtools/python/python3-meson-python_0.13.1.bb new file +23 -0
new file mode 100644
index 000000000..6b9ff24f2
@@ -0,0 +1,23 @@
+SUMMARY = "Meson Python build backend (PEP 517)"
+HOMEPAGE = "https://github.com/mesonbuild/meson-python"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=d580b27e67cc0892a5b005b0be114b60"
+
+DEPENDS = " \
+	meson-native ninja-native patchelf-native \
+	python3-pyproject-metadata-native \
+"
+
+PYPI_PACKAGE = "meson_python"
+
+inherit pypi python_mesonpy
+SRC_URI[sha256sum] = "63b3170001425c42fa4cfedadb9051cbd28925ff8eed7c40d36ba0099e3c7618"
+
+DEPENDS:remove:class-native = "python3-meson-python-native"
+
+RDEPENDS:${PN} = " \
+	meson ninja patchelf \
+	python3-pyproject-metadata \
+"
+
+BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.40.1
#1 lore raw

PATCH 2/2 python_mesonpy: New class

This is a new PEP517 compatible build class for python modules that use pyproject.toml and this:

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

The new class uses python3-meson-python-native.

---
 meta-python/classes/python_mesonpy.bbclass | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 meta-python/classes/python_mesonpy.bbclass
meta-python/classes/python_mesonpy.bbclass new file +54 -0
new file mode 100644
index 000000000..1da8b005a
@@ -0,0 +1,54 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit meson setuptools3-base python3targetconfig python_pep517
+
+# Filter out meson_do_qa_configure from do_configure[postfuncs]
+DOCONFIGUREPOSTFUNCS := "${@d.getVarFlag('do_configure', 'postfuncs')}"
+DOCONFIGUREPOSTFUNCS:remove = "meson_do_qa_configure"
+do_configure[postfuncs] := "${@'' if d.getVar('DOCONFIGUREPOSTFUNCS') is None else d.getVar('DOCONFIGUREPOSTFUNCS') }"
+
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"
+
+CONFIGURE_FILES = "pyproject.toml"
+
+DEPENDS += "python3-wheel-native python3-meson-python-native"
+
+def mesonpy_get_args(d):
+    vars = ['MESONOPTS', 'MESON_CROSS_FILE', 'EXTRA_OEMESON']
+    varlist = []
+    for var in vars:
+        value = d.getVar(var)
+        vallist = value.split()
+        for elem in vallist:
+            varlist.append("-Csetup-args=" + elem)
+    return ' '.join(varlist)
+
+PEP517_BUILD_OPTS = "-Cbuilddir='${B}' ${@mesonpy_get_args(d)}"
+
+# Python pyx -> c -> so build leaves absolute build paths in the code
+INSANE_SKIP:${PN} += "buildpaths"
+INSANE_SKIP:${PN}-src += "buildpaths"
+
+python_mesonpy_do_configure () {
+    python_pep517_do_configure
+}
+
+python_mesonpy_do_compile () {
+    python_pep517_do_compile
+}
+
+python_mesonpy_do_install () {
+    python_pep517_do_install
+}
+
+python_mesonpy_do_bootstrap_install () {
+    python_pep517_do_bootstrap_install
+}
+
+EXPORT_FUNCTIONS do_configure do_compile do_install
Signature · 1 line
2.40.1
#2 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

meta-python/classes/python_mesonpy.bbclass line 12

Quoted 4 lines · Zoltan Boszormenyi via lists.openembedded.org
meta-python/classes/python_mesonpy.bbclass new file +4 -0
+# Filter out meson_do_qa_configure from do_configure[postfuncs]
+DOCONFIGUREPOSTFUNCS := "${@d.getVarFlag('do_configure', 'postfuncs')}"
+DOCONFIGUREPOSTFUNCS:remove = "meson_do_qa_configure"
+do_configure[postfuncs] := "${@'' if d.getVar('DOCONFIGUREPOSTFUNCS') is None else d.getVar('DOCONFIGUREPOSTFUNCS') }"

A neater solution would be to just stub out meson_do_qa_configure in this class:

meson_do_qa_configure() { : }

meta-python/classes/python_mesonpy.bbclass line 16

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right? Might be better to patch mesonpy instead.

meta-python/classes/python_mesonpy.bbclass line 52

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+python_mesonpy_do_bootstrap_install () {
+    python_pep517_do_bootstrap_install
+}

This looks redundant and nothing calls it, remove.

Ross

#3 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

2023. 06. 07. 11:57 keltezéssel, Ross Burton írta:

Quoted 8 lines · Zoltan Boszormenyi via lists.openembedded.org

meta-python/classes/python_mesonpy.bbclass line 12

Quoted 4 lines
meta-python/classes/python_mesonpy.bbclass new file +4 -0
+# Filter out meson_do_qa_configure from do_configure[postfuncs]
+DOCONFIGUREPOSTFUNCS := "${@d.getVarFlag('do_configure', 'postfuncs')}"
+DOCONFIGUREPOSTFUNCS:remove = "meson_do_qa_configure"
+do_configure[postfuncs] := "${@'' if d.getVar('DOCONFIGUREPOSTFUNCS') is None else d.getVar('DOCONFIGUREPOSTFUNCS') }"

A neater solution would be to just stub out meson_do_qa_configure in this class:

meson_do_qa_configure() { : }

Thanks. I will make this change.

Quoted 4 lines

meta-python/classes/python_mesonpy.bbclass line 16

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right? Might be better to patch mesonpy instead.

Why would it break? It does not affect what meson-python is adding internally.

This only removes the setting imposed by meson.bbclass and only needs to change if meson.bbclass switches to -Dbuildtype.

Quoted 4 lines

meta-python/classes/python_mesonpy.bbclass line 52

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+python_mesonpy_do_bootstrap_install () {
+    python_pep517_do_bootstrap_install
+}

This looks redundant and nothing calls it, remove.

Ok.

#4 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

Quoted 9 lines · Böszörményi Zoltán
Quoted 4 lines

meta-python/classes/python_mesonpy.bbclass line 16

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right? Might be better to patch mesonpy instead.

Why would it break? It does not affect what meson-python is adding internally.

This only removes the setting imposed by meson.bbclass and only needs to change if meson.bbclass switches to -Dbuildtype.

My understanding is that meson.bbclass is passing —buildtype and then mesonpy is passing -Dbuildtype.

This :remove removes any —buildtype option, so if mesonpy changes to using —buildtype instead of -Dbuildtype then _both_ buildtype options will be removed, which isn’t what you want.

Ross

#5 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

2023. 06. 07. 13:26 keltezéssel, Ross Burton írta:

Quoted 10 lines · Böszörményi Zoltán
Quoted 8 lines
Quoted 4 lines

meta-python/classes/python_mesonpy.bbclass line 16

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right? Might be better to patch mesonpy instead.

Why would it break? It does not affect what meson-python is adding internally.

This only removes the setting imposed by meson.bbclass and only needs to change if meson.bbclass switches to -Dbuildtype.

My understanding is that meson.bbclass is passing —buildtype and then mesonpy is passing -Dbuildtype.

Correct.

Quoted 1 line

This :remove removes any —buildtype option, so if mesonpy changes to using —buildtype instead of -Dbuildtype then _both_ buildtype options will be removed, which isn’t what you want.

Wrong.

This only removes the --buildtype setting from MESONOPTS set by meson.bbclass. This variable is internal to meson.bbclass, not exported.
It it used this way there:

meson setup ${MESONOPTS} ...

mesonpy doesn't use the MESONOPTS variable to set the buildtype and since this variable is not exported, meson can't see or use it either.

#6 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

Quoted 13 lines · Böszörményi Zoltán

2023. 06. 07. 13:26 keltezéssel, Ross Burton írta:

Quoted 10 lines · Böszörményi Zoltán
Quoted 8 lines
Quoted 4 lines

meta-python/classes/python_mesonpy.bbclass line 16

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right? Might be better to patch mesonpy instead.

Why would it break? It does not affect what meson-python is adding internally.

This only removes the setting imposed by meson.bbclass and only needs to change if meson.bbclass switches to -Dbuildtype.

My understanding is that meson.bbclass is passing —buildtype and then mesonpy is passing -Dbuildtype.

Quoted 7 lines

Correct.

Quoted 1 line

This :remove removes any —buildtype option, so if mesonpy changes to using —buildtype instead of -Dbuildtype then _both_ buildtype options will be removed, which isn’t what you want.

Wrong.

This only removes the --buildtype setting from MESONOPTS set by meson.bbclass.

Okay, I take it back, thanks.

Ross

#7 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

2023. 06. 07. 17:35 keltezéssel, Ross Burton írta:

Quoted 11 lines · Böszörményi Zoltán
Quoted 10 lines

2023. 06. 07. 13:26 keltezéssel, Ross Burton írta:

Quoted 9 lines · Böszörményi Zoltán
Quoted 8 lines
Quoted 4 lines

meta-python/classes/python_mesonpy.bbclass line 16

Quoted 3 lines
meta-python/classes/python_mesonpy.bbclass new file +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right? Might be better to patch mesonpy instead.

Why would it break? It does not affect what meson-python is adding internally.

This only removes the setting imposed by meson.bbclass and only needs to change if meson.bbclass switches to -Dbuildtype.

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

My understanding is that meson.bbclass is passing —buildtype and then mesonpy is passing -Dbuildtype.

Correct.

Quoted 1 line

This :remove removes any —buildtype option, so if mesonpy changes to using —buildtype instead of -Dbuildtype then _both_ buildtype options will be removed, which isn’t what you want.

Wrong.

This only removes the --buildtype setting from MESONOPTS set by meson.bbclass.

Okay, I take it back, thanks.

Thanks. I will send the updated series shortly.

As a side note, do you know why -I/usr/include/python3.11 may get added to the build command by meson? It happens on a Fedora 38 build host but it doesn't happen on a Fedora 33 build host. As a result, building my in-house python3-scikit-image recipe fails on Fedora 38.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: [oe] [meta-python][PATCH 2/2] python_mesonpy: New class

2023. 06. 08. 13:30 keltezéssel, Zoltan Boszormenyi via lists.openembedded.org írta:

Quoted 19 lines

2023. 06. 07. 17:35 keltezéssel, Ross Burton írta:

Quoted 18 lines · Böszörményi Zoltán
Quoted 17 lines

2023. 06. 07. 13:26 keltezéssel, Ross Burton írta:

Quoted 10 lines · Böszörményi Zoltán
Quoted 8 lines
Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+# This prevents the meson error:
+# ERROR: Got argument buildtype as both -Dbuildtype and --buildtype. Pick one.
+MESONOPTS:remove = "--buildtype ${MESON_BUILDTYPE}"

If mesonpy ever switches to —buildtype then this will break, right?  Might be better to patch mesonpy instead.

Why would it break? It does not affect what meson-python is adding internally.

This only removes the setting imposed by meson.bbclass and only needs to change if meson.bbclass switches to -Dbuildtype.

My understanding is that meson.bbclass is passing —buildtype and then mesonpy is passing -Dbuildtype.

Correct.

Quoted 1 line

This :remove removes any —buildtype option, so if mesonpy changes to using —buildtype instead of -Dbuildtype then _both_ buildtype options will be removed, which isn’t what you want.

Wrong.

This only removes the --buildtype setting from MESONOPTS set by meson.bbclass.

Quoted 8 lines
Quoted 1 line

Okay, I take it back, thanks.

Thanks. I will send the updated series shortly.

As a side note, do you know why -I/usr/include/python3.11 may get added to the build command by meson? It happens on a Fedora 38 build host but it doesn't happen on a Fedora 33 build host. As a result, building my in-house python3-scikit-image recipe fails on Fedora 38.

Nevermind, it's fixed by adding "inherit pkgconfig" to the recipe.

Quoted 10 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#103186): https://lists.openembedded.org/g/openembedded-devel/message/103186
Mute This Topic: https://lists.openembedded.org/mt/99379800/3617728
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-