setuptools3.bbclass: add check for pyproject.toml
PATCH v3 1/1 setuptools3.bbclass: add check for pyproject.toml
From: Tim Orling <[email protected]>
With help from Peter Kjellerstedt <[email protected]> via IRC.
Add a check for pyproject.toml in ${S} and if so check if it has a [build-system] build-backend. Give the user a helpful warning that the recipe should be changed to one of the PEP-517 classes (instead of setuptools3.bbclass).
Add SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK variable to skip this check (and avoid the warning). This is needed for e.g. python3-setuptools-rust-native which does not build cleanly with setuptools_build_meta.bbclass
Because some sources have a pyproject.toml but no [build-sytem] or no properly defined (or accurate) build-backend, add a try: except: clause to avoid KeyError.
[YOCTO #14736]
--- meta/classes/setuptools3.bbclass | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
meta/classes/setuptools3.bbclass +41 -0
@@ -18,6 +18,47 @@ setuptools3_do_configure() { : } +SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK ?= "0" + +python check_for_pyprojecttoml_build_backend() { + import os + import tomli + from pathlib import Path + + if d.getVar('SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK') == "1": + bb.debug(3, "Skipping check for build-backend in pyproject.toml") + return 0 + warn_string = "The source has a pyproject.toml which declares '%s' as a build backend, please consider 'inherit %s' instead of inheriting setuptools3." + warn_layer_string = "The source has a pyproject.toml which declares '%s' as a build backend, please consider 'inherit %s' from %s instead of inheriting setuptools3." + pyprojecttoml_file = Path(d.getVar('S'), 'pyproject.toml') + if pyprojecttoml_file.exists(): + bb.debug(3, "pyproject.toml found: %s" % pyprojecttoml_file) + with open(pyprojecttoml_file, "rb") as f: + pyprojecttoml_dict = tomli.load(f) + try: + build_system = pyprojecttoml_dict["build-system"] + if build_system: + bb.debug(3, "[build-system] found in pyproject.toml") + backend = build_system.get('build-backend') + if backend: + bb.debug(3, "build-backend found: %s" % backend) + if backend == "flit_core.buildapi": + bb.warn(warn_string % ('flit_core.buildapi', + 'flit_core')) + elif backend == "setuptools.build_meta": + bb.warn(warn_string % ('setuptools.build_meta', + 'setuptools_build_meta')) + elif backend == "poetry.core.masonry.api": + bb.warn(warn_layer_string % ('poetry.core.masonry.api', + 'poetry_core', 'meta-python')) + else: + bb.warn("The source has a pyproject.toml which declares '%s' as a build backend, but this is not currently supported in oe-core." % backend) + except KeyError: + bb.warn("The source has a pyproject.toml, but either no [build-system] or it is malformed. If the recipe is still buildable with setuptools3, you can skip this check with:\nSETUPTOOLS_SKIP_BUILD_BACKEND_CHECK= \"1\"") + pass +} +do_configure[prefuncs] += "check_for_pyprojecttoml_build_backend" + setuptools3_do_compile() { cd ${SETUPTOOLS_SETUP_PATH} NO_FETCH_BUILD=1 \
Signature · 1 line
2.30.2
Quoted 30 lines · Tim Orling
From: Tim Orling <[email protected]>
With help from Peter Kjellerstedt <[email protected]> via IRC.
Add a check for pyproject.toml in ${S} and if so check if it has a [build-system] build-backend. Give the user a helpful warning that the recipe should be changed to one of the PEP-517 classes (instead of setuptools3.bbclass).
Add
SETUPTOOLS_SKIP_BUILD_BACKEND_CHECKvariable to skip this check (and avoid the warning). This is needed for e.g. python3-setuptools-rust-native which does not build cleanly with setuptools_build_meta.bbclassBecause some sources have a pyproject.toml but no [build-sytem] or no properly defined (or accurate) build-backend, add a try: except: clause to avoid KeyError.
[YOCTO #14736]
Signed-off-by Tim Orling <[email protected]>--- meta/classes/setuptools3.bbclass | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)meta/classes/setuptools3.bbclass +0
-0
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 25
Quoted 8 lines
meta/classes/setuptools3.bbclass +5
-0@@ -18,6 +18,47 @@ setuptools3_do_configure() { : } +SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK ?= "0" + +python check_for_pyprojecttoml_build_backend() { + import os + import tomli
https://autobuilder.yoctoproject.org/typhoon/#/builders/65/builds/4833/steps/12/logs/stdio
Exception: ModuleNotFoundError: No module named 'tomli'
Cheers,
Richard
Quoted 47 lines
meta/classes/setuptools3.bbclass +36
-1+ from pathlib import Path + + if d.getVar('SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK') == "1": + bb.debug(3, "Skipping check for build-backend in pyproject.toml") + return 0 + warn_string = "The source has a pyproject.toml which declares '%s' as a build backend, please consider 'inherit %s' instead of inheriting setuptools3." + warn_layer_string = "The source has a pyproject.toml which declares '%s' as a build backend, please consider 'inherit %s' from %s instead of inheriting setuptools3." + pyprojecttoml_file = Path(d.getVar('S'), 'pyproject.toml') + if pyprojecttoml_file.exists(): + bb.debug(3, "pyproject.toml found: %s" % pyprojecttoml_file) + with open(pyprojecttoml_file, "rb") as f: + pyprojecttoml_dict = tomli.load(f) + try: + build_system = pyprojecttoml_dict["build-system"] + if build_system: + bb.debug(3, "[build-system] found in pyproject.toml") + backend = build_system.get('build-backend') + if backend: + bb.debug(3, "build-backend found: %s" % backend) + if backend == "flit_core.buildapi": + bb.warn(warn_string % ('flit_core.buildapi', + 'flit_core')) + elif backend == "setuptools.build_meta": + bb.warn(warn_string % ('setuptools.build_meta', + 'setuptools_build_meta')) + elif backend == "poetry.core.masonry.api": + bb.warn(warn_layer_string % ('poetry.core.masonry.api', + 'poetry_core', 'meta-python')) + else: + bb.warn("The source has a pyproject.toml which declares '%s' as a build backend, but this is not currently supported in oe-core." % backend) + except KeyError: + bb.warn("The source has a pyproject.toml, but either no [build-system] or it is malformed. If the recipe is still buildable with setuptools3, you can skip this check with:\nSETUPTOOLS_SKIP_BUILD_BACKEND_CHECK= \"1\"") + pass +} +do_configure[prefuncs] += "check_for_pyprojecttoml_build_backend" + setuptools3_do_compile() { cd ${SETUPTOOLS_SETUP_PATH} NO_FETCH_BUILD=1 \ -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#162414): https://lists.openembedded.org/g/openembedded-core/message/162414
Mute This Topic: https://lists.openembedded.org/mt/89401217/1686473
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 44 lines · Richard Purdie
Quoted 18 lines · Tim Orling
From: Tim Orling <[email protected]>
With help from Peter Kjellerstedt <[email protected]> via IRC.
Add a check for pyproject.toml in ${S} and if so check if it has a [build-system] build-backend. Give the user a helpful warning that the recipe should be changed to one of the PEP-517 classes (instead of setuptools3.bbclass).
Add
SETUPTOOLS_SKIP_BUILD_BACKEND_CHECKvariable to skip this check (and avoid the warning). This is needed for e.g. python3-setuptools-rust-native which does not build cleanly with setuptools_build_meta.bbclassBecause some sources have a pyproject.toml but no [build-sytem] or no properly defined (or accurate) build-backend, add a try: except: clause to avoid KeyError.
Review
Quoted 8 lines
[YOCTO #14736]
Signed-off-by Tim Orling <[email protected]>--- meta/classes/setuptools3.bbclass | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)(quoted diff) +0
-0b/meta/classes/setuptools3.bbclass
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 25
Quoted 12 lines
index
12561340b07..d80a91d3296100644meta/classes/setuptools3.bbclass +5
-0@@ -18,6 +18,47 @@ setuptools3_do_configure() { : } +SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK ?= "0" + +python check_for_pyprojecttoml_build_backend() { + import os + import tomlihttps://autobuilder.yoctoproject.org/typhoon/#/builders/65/builds/4833/steps/12/logs/stdio
Quoted 2 lines
Exception: ModuleNotFoundError: No module named 'tomli'
Ah. Right. This is the chicken and egg problem of needing a TOML parser. I really wish upstream had added one to the standard libs.
Quoted 70 lines
Cheers,
Richard
meta/classes/setuptools3.bbclass setuptools3_do_configure() {
Quoted 4 lines
meta/classes/setuptools3.bbclass +4
-0+ from pathlib import Path + + if d.getVar('SETUPTOOLS_SKIP_BUILD_BACKEND_CHECK') == "1": + bb.debug(3, "Skipping check for build-backend inpyproject.toml")
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 31
Quoted 2 lines
meta/classes/setuptools3.bbclass +2
-0+ return 0 + warn_string = "The source has a pyproject.toml which declares '%s'as a build backend, please consider 'inherit %s' instead of inheriting setuptools3."
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 32
Quoted 1 line
meta/classes/setuptools3.bbclass +1
-0+ warn_layer_string = "The source has a pyproject.toml which declares'%s' as a build backend, please consider 'inherit %s' from %s instead of inheriting setuptools3."
meta/classes/setuptools3.bbclass setuptools3_do_configure() {
Quoted 9 lines
meta/classes/setuptools3.bbclass +9
-0+ pyprojecttoml_file = Path(d.getVar('S'), 'pyproject.toml') + if pyprojecttoml_file.exists(): + bb.debug(3, "pyproject.toml found: %s" % pyprojecttoml_file) + with open(pyprojecttoml_file, "rb") as f: + pyprojecttoml_dict = tomli.load(f) + try: + build_system = pyprojecttoml_dict["build-system"] + if build_system: + bb.debug(3, "[build-system] found inpyproject.toml")
meta/classes/setuptools3.bbclass setuptools3_do_configure() {
Quoted 11 lines
meta/classes/setuptools3.bbclass +11
-0+ backend = build_system.get('build-backend') + if backend: + bb.debug(3, "build-backend found: %s" % backend) + if backend == "flit_core.buildapi": + bb.warn(warn_string % ('flit_core.buildapi', + 'flit_core')) + elif backend == "setuptools.build_meta": + bb.warn(warn_string % ('setuptools.build_meta', + 'setuptools_build_meta')) + elif backend == "poetry.core.masonry.api": + bb.warn(warn_layer_string %('poetry.core.masonry.api',
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 53
Quoted 1 line
meta/classes/setuptools3.bbclass +1
-0+ 'poetry_core','meta-python'))
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 55
Quoted 2 lines
meta/classes/setuptools3.bbclass +2
-0+ else: + bb.warn("The source has a pyproject.toml whichdeclares '%s' as a build backend, but this is not currently supported in oe-core." % backend)
meta/classes/setuptools3.bbclass setuptools3_do_configure() { · line 57
Quoted 2 lines
meta/classes/setuptools3.bbclass +2
-0+ except KeyError: + bb.warn("The source has a pyproject.toml, but either no[build-system] or it is malformed. If the recipe is still buildable with setuptools3, you can skip this check with:\nSETUPTOOLS_SKIP_BUILD_BACKEND_CHECK= \"1\"")
Quoted 10 lines
meta/classes/setuptools3.bbclass +4
-1+ pass +} +do_configure[prefuncs] += "check_for_pyprojecttoml_build_backend" + setuptools3_do_compile() { cd ${SETUPTOOLS_SETUP_PATH} NO_FETCH_BUILD=1 \ -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group. View/Reply Online (#162414):
https://lists.openembedded.org/g/openembedded-core/message/162414
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/89401217/1686473
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-