diff mbox series

[meta-python,1/4] python_setuptools_build_meta_mesonpy.bbclass: New class

Message ID 20230315080429.2722555-1-zboszor@gmail.com
State Under Review
Headers show
Series [meta-python,1/4] python_setuptools_build_meta_mesonpy.bbclass: New class | expand

Commit Message

Böszörményi Zoltán March 15, 2023, 8:04 a.m. UTC
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@gmail.com>
---
 ...python_setuptools_build_meta_mesonpy.bbclass | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass

Comments

Ross Burton March 15, 2023, 12:46 p.m. UTC | #1
On 15 Mar 2023, at 08:04, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
> 
> 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.

So the pep517 build thing provides dependencies (which we ignore), build isolation (which we disable), and automatic use of the right tooling (which we have to specify manually).

So what does the meson-python integration bring?  Can we just run meson directly?

> +DEPENDS += "python3-setuptools-native python3-wheel-native ${@'' if d.getVar('PN') == 'python3-meson-python-native' else 'python3-meson-python-native’}"

FWIW, all the other pep517 classes have a “neat” depends without logic and expect the recipe (python3-meson-python-native in this case) to remove itself from the DEPENDS.

Ross
Böszörményi Zoltán March 15, 2023, 2:16 p.m. UTC | #2
2023. 03. 15. 13:46 keltezéssel, Ross Burton írta:
> On 15 Mar 2023, at 08:04, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
>> 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.
> So the pep517 build thing provides dependencies (which we ignore),

Does this mean recipes using this class would specify the
build dependencies themselves instead of having them
brought in via the class?

> build isolation (which we disable), and automatic use of the right tooling (which we have to specify manually).

Not sure what this means, please elaborate.
Please instruct me what clean up in this class to get this acceptible.

meta-scipy has a quite old SciPy version and the latest version uses this thing.
I have a working scikit-image 0.20.0 recipe also using this.

> So what does the meson-python integration bring?  Can we just run meson directly?

Unfortunately, no.

meson itself does not provide a PEP517 compliant build backend.
meson-python (mesonpy, https://pypi.org/project/meson-python/) does that as a wrapper over 
meson.

I tried just using meson, but while it the .so parts were built,
none of the .py files were properly owned and no egg metadata
was generated. While the first issue is fixable in the recipe,
the second isn't.

This resulted in that the presence of the mesonpy and its version
were not detected by a dependee module's build system e.g.
scikit-image. I would expect any project using build-backend = 'mesonpy'
would fail without the detecting the meson-python module.

>> +DEPENDS += "python3-setuptools-native python3-wheel-native ${@'' if d.getVar('PN') == 'python3-meson-python-native' else 'python3-meson-python-native’}"
> FWIW, all the other pep517 classes have a “neat” depends without logic and expect the recipe (python3-meson-python-native in this case) to remove itself from the DEPENDS.

Thanks for the pointer, I will make this change.
Ross Burton March 15, 2023, 6:08 p.m. UTC | #3
On 15 Mar 2023, at 14:16, Böszörményi Zoltán <zboszor@gmail.com> wrote:
> 
> 2023. 03. 15. 13:46 keltezéssel, Ross Burton írta:
>> On 15 Mar 2023, at 08:04, Zoltan Boszormenyi via lists.openembedded.org <zboszor=gmail.com@lists.openembedded.org> wrote:
>>> 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.
>> So the pep517 build thing provides dependencies (which we ignore),
> 
> Does this mean recipes using this class would specify the
> build dependencies themselves instead of having them
> brought in via the class?

Yes. That’s explicit and intentionally the desired behaviour.  Dependencies are declared in the recipe.

>> build isolation (which we disable), and automatic use of the right tooling (which we have to specify manually).
> 
> Not sure what this means, please elaborate.

The python ‘build’ tool can do builds inside a minimal virtual environment. We deliberately don’t do this: dependencies are expected to be in the sysroot via DEPENDS, and they should be used. build won’t be able to fetch anything else during do_compile anyway, as the network is disabled.

build also reads the pyproject.toml to determine what build tool to use.  As we need dependencies up front this isn’t possible.

> Please instruct me what clean up in this class to get this acceptible.
> 
> meta-scipy has a quite old SciPy version and the latest version uses this thing.
> I have a working scikit-image 0.20.0 recipe also using this.
> 
>> So what does the meson-python integration bring?  Can we just run meson directly?
> 
> Unfortunately, no.
> 
> meson itself does not provide a PEP517 compliant build backend.
> meson-python (mesonpy, https://pypi.org/project/meson-python/) does that as a wrapper over meson.

Right, but if we’re just calling meson that isn’t relevant.

> I tried just using meson, but while it the .so parts were built,
> none of the .py files were properly owned and no egg metadata
> was generated. While the first issue is fixable in the recipe,
> the second isn’t.

So the point of meson-python is to write the package metadata, right.

It seems very overcomplicated for such a simple job, but fine.

I’ll give this another review tomorrow, but fyi you can remove the setuptools dependency.

Ross
Tim Orling March 16, 2023, 3:51 p.m. UTC | #4
On Wed, Mar 15, 2023 at 1:04 AM Zoltan Boszormenyi <zboszor@gmail.com>
wrote:

> 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@gmail.com>
> ---
>  ...python_setuptools_build_meta_mesonpy.bbclass | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644
> meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
>

The name of the class is overly long. If you look at the other classes in
oe-core, they basically use the build-backend value,
prefixed with the "python_" namespace, so I would propose just
"python_mesonpy.bbclass"

The python_setuptools_build_meta.bbclass was named as such because the
build-backend is "setuptools.build_meta"
such as in https://github.com/jaraco/zipp/blob/main/pyproject.toml#L3


> diff --git
> a/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
> b/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
> new file mode 100644
> index 000000000..1d3fdbd7c
> --- /dev/null
> +++ b/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
> @@ -0,0 +1,17 @@
> +#
> +# Copyright OpenEmbedded Contributors
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +inherit setuptools3-base pkgconfig meson-common python3targetconfig
> python_pep517
> +
> +DEPENDS += "python3-setuptools-native python3-wheel-native ${@'' if
> d.getVar('PN') == 'python3-meson-python-native' else
> '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
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#101529):
> https://lists.openembedded.org/g/openembedded-devel/message/101529
> Mute This Topic: https://lists.openembedded.org/mt/97622993/924729
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [
> ticotimo@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Böszörményi Zoltán March 16, 2023, 4:36 p.m. UTC | #5
2023. 03. 16. 16:51 keltezéssel, Tim Orling írta:
>
>
> On Wed, Mar 15, 2023 at 1:04 AM Zoltan Boszormenyi <zboszor@gmail.com> wrote:
>
>     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@gmail.com>
>     ---
>      ...python_setuptools_build_meta_mesonpy.bbclass | 17 +++++++++++++++++
>      1 file changed, 17 insertions(+)
>      create mode 100644 meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
>
>
> The name of the class is overly long. If you look at the other classes in oe-core, they 
> basically use the build-backend value,
> prefixed with the "python_" namespace, so I would propose just "python_mesonpy.bbclass"

I agree. I will shorten the name of the class.

>
> The python_setuptools_build_meta.bbclass was named as such because the build-backend is 
> "setuptools.build_meta"
> such as in https://github.com/jaraco/zipp/blob/main/pyproject.toml#L3
>
>
>     diff --git a/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
>     b/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
>     new file mode 100644
>     index 000000000..1d3fdbd7c
>     --- /dev/null
>     +++ b/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
>     @@ -0,0 +1,17 @@
>     +#
>     +# Copyright OpenEmbedded Contributors
>     +#
>     +# SPDX-License-Identifier: MIT
>     +#
>     +
>     +inherit setuptools3-base pkgconfig meson-common python3targetconfig python_pep517
>     +
>     +DEPENDS += "python3-setuptools-native python3-wheel-native ${@'' if d.getVar('PN')
>     == 'python3-meson-python-native' else '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
>
>
>     -=-=-=-=-=-=-=-=-=-=-=-
>     Links: You receive all messages sent to this group.
>     View/Reply Online (#101529):
>     https://lists.openembedded.org/g/openembedded-devel/message/101529
>     Mute This Topic: https://lists.openembedded.org/mt/97622993/924729
>     Group Owner: openembedded-devel+owner@lists.openembedded.org
>     <mailto:openembedded-devel%2Bowner@lists.openembedded.org>
>     Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub
>     [ticotimo@gmail.com]
>     -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass b/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
new file mode 100644
index 000000000..1d3fdbd7c
--- /dev/null
+++ b/meta-python/classes/python_setuptools_build_meta_mesonpy.bbclass
@@ -0,0 +1,17 @@ 
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit setuptools3-base pkgconfig meson-common python3targetconfig python_pep517
+
+DEPENDS += "python3-setuptools-native python3-wheel-native ${@'' if d.getVar('PN') == 'python3-meson-python-native' else '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"