diff mbox series

[3/3] python_mesonpy: New class

Message ID 20230602074419.2450399-3-zboszor@gmail.com
State New
Headers show
Series [1/3] python3-pyproject-metadata: New recipe | expand

Commit Message

Böszörményi Zoltán June 2, 2023, 7:44 a.m. UTC
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.

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

Comments

Richard Purdie June 13, 2023, 8:59 p.m. UTC | #1
On Fri, 2023-06-02 at 09:44 +0200, Zoltan Boszormenyi wrote:
> 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.
> 
> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> ---
>  meta/classes-recipe/python_mesonpy.bbclass | 54 ++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>  create mode 100644 meta/classes-recipe/python_mesonpy.bbclass
> 
> diff --git a/meta/classes-recipe/python_mesonpy.bbclass b/meta/classes-recipe/python_mesonpy.bbclass
> new file mode 100644
> index 0000000000..1da8b005ab
> --- /dev/null
> +++ b/meta/classes-recipe/python_mesonpy.bbclass
> @@ -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"

This is not ready for core as the output is not reproducible. I am not
taking patches which skip buildpaths warnings.

This also shows that the code is not being tested in OE-Core. Until it
is needed by and being used by something in core, I don't think it
should be there.

Cheers,

Richard
Böszörményi Zoltán June 14, 2023, 5:46 a.m. UTC | #2
2023. 06. 13. 22:59 keltezéssel, Richard Purdie írta:
> On Fri, 2023-06-02 at 09:44 +0200, Zoltan Boszormenyi wrote:
>> 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.
>>
>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>> ---
>>   meta/classes-recipe/python_mesonpy.bbclass | 54 ++++++++++++++++++++++
>>   1 file changed, 54 insertions(+)
>>   create mode 100644 meta/classes-recipe/python_mesonpy.bbclass
>>
>> diff --git a/meta/classes-recipe/python_mesonpy.bbclass b/meta/classes-recipe/python_mesonpy.bbclass
>> new file mode 100644
>> index 0000000000..1da8b005ab
>> --- /dev/null
>> +++ b/meta/classes-recipe/python_mesonpy.bbclass
>> @@ -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"
> This is not ready for core as the output is not reproducible. I am not
> taking patches which skip buildpaths warnings.
>
> This also shows that the code is not being tested in OE-Core. Until it
> is needed by and being used by something in core, I don't think it
> should be there.

This thread was long time dead. The series was sent to meta-oe.

>
> Cheers,
>
> Richard
>
Richard Purdie June 14, 2023, 9:52 a.m. UTC | #3
On Wed, 2023-06-14 at 07:46 +0200, Böszörményi Zoltán wrote:
> 2023. 06. 13. 22:59 keltezéssel, Richard Purdie írta:
> > On Fri, 2023-06-02 at 09:44 +0200, Zoltan Boszormenyi wrote:
> > > 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.
> > > 
> > > Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
> > > ---
> > >   meta/classes-recipe/python_mesonpy.bbclass | 54 ++++++++++++++++++++++
> > >   1 file changed, 54 insertions(+)
> > >   create mode 100644 meta/classes-recipe/python_mesonpy.bbclass
> > > 
> > > diff --git a/meta/classes-recipe/python_mesonpy.bbclass b/meta/classes-recipe/python_mesonpy.bbclass
> > > new file mode 100644
> > > index 0000000000..1da8b005ab
> > > --- /dev/null
> > > +++ b/meta/classes-recipe/python_mesonpy.bbclass
> > > @@ -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"
> > This is not ready for core as the output is not reproducible. I am not
> > taking patches which skip buildpaths warnings.
> > 
> > This also shows that the code is not being tested in OE-Core. Until it
> > is needed by and being used by something in core, I don't think it
> > should be there.
> 
> This thread was long time dead. The series was sent to meta-oe.

Was the reproducibility issue fixed? It really does need to be as we
have things like hash equivalence which depend upon that...

Cheers,

Richard
Böszörményi Zoltán June 14, 2023, 12:27 p.m. UTC | #4
2023. 06. 14. 11:52 keltezéssel, Richard Purdie írta:
> On Wed, 2023-06-14 at 07:46 +0200, Böszörményi Zoltán wrote:
>> 2023. 06. 13. 22:59 keltezéssel, Richard Purdie írta:
>>> On Fri, 2023-06-02 at 09:44 +0200, Zoltan Boszormenyi wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>> ---
>>>>    meta/classes-recipe/python_mesonpy.bbclass | 54 ++++++++++++++++++++++
>>>>    1 file changed, 54 insertions(+)
>>>>    create mode 100644 meta/classes-recipe/python_mesonpy.bbclass
>>>>
>>>> diff --git a/meta/classes-recipe/python_mesonpy.bbclass b/meta/classes-recipe/python_mesonpy.bbclass
>>>> new file mode 100644
>>>> index 0000000000..1da8b005ab
>>>> --- /dev/null
>>>> +++ b/meta/classes-recipe/python_mesonpy.bbclass
>>>> @@ -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"
>>> This is not ready for core as the output is not reproducible. I am not
>>> taking patches which skip buildpaths warnings.
>>>
>>> This also shows that the code is not being tested in OE-Core. Until it
>>> is needed by and being used by something in core, I don't think it
>>> should be there.
>> This thread was long time dead. The series was sent to meta-oe.
> Was the reproducibility issue fixed?

You tell me. This is something to be fixed in Cython, as the
pyx -> C/C++ translation is responsible for those warnings,
not mesonpy.

I am happy to remove those INSANE_SKIP settings, though.

>   It really does need to be as we
> have things like hash equivalence which depend upon that...
>
> Cheers,
>
> Richard
diff mbox series

Patch

diff --git a/meta/classes-recipe/python_mesonpy.bbclass b/meta/classes-recipe/python_mesonpy.bbclass
new file mode 100644
index 0000000000..1da8b005ab
--- /dev/null
+++ b/meta/classes-recipe/python_mesonpy.bbclass
@@ -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