From patchwork Wed Sep 9 21:55:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 97791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F307C79FB6 for ; Wed, 9 Sep 2026 21:55:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.151.1788990942035727871 for ; Wed, 09 Sep 2026 14:55:42 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@arm.com header.s=foss header.b=qMYVYkvH; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9637B1570 for ; Wed, 9 Sep 2026 14:55:37 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C9D5E3F7B4 for ; Wed, 9 Sep 2026 14:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1788990941; bh=EvPeJf15Waj3kWSgqzW2SDnnm6qoOm5uvbCUx4rpIHo=; h=From:To:Subject:Date:From; b=qMYVYkvHNiU6sM9peWVHsyIsrZgCx9/uVsT37ua2JZoLeiIXeOlNfptw8sP0Vpmnw InAWn9KtxEOyXhwSFfytIS8E0u4FzBMEQjXAyrMYH0M0oqiT48gc7CCOME5g/2tYPd uCk9Hp4mSZNgbHO0NE8fifxpOqkUQ4qJGTsOIS4o= From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v2 1/2] classes/setuptools: use tomllib instead of regex to parse pyproject.toml Date: Wed, 9 Sep 2026 22:55:36 +0100 Message-ID: <20260909215537.51943-1-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 09 Sep 2026 21:55:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/245518 BitBake now vendors in tomli[1] for when the host Python is older than 3.11 so doesn't have tomllib. Rewrite the pyproject.toml parsing from regexs to tomllib. Also ensure that the functions in setuptools3 and setuptools_legacy are identical, as they had diverged. [1] bitbake 69810e0c0a ("lib/bb/_vendor: resync to add tomli") Signed-off-by: Ross Burton --- meta/classes-recipe/setuptools3.bbclass | 24 +++++++++++---- .../classes-recipe/setuptools3_legacy.bbclass | 29 ++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/meta/classes-recipe/setuptools3.bbclass b/meta/classes-recipe/setuptools3.bbclass index b0e4ab5208c..d64e5bdba3a 100644 --- a/meta/classes-recipe/setuptools3.bbclass +++ b/meta/classes-recipe/setuptools3.bbclass @@ -13,19 +13,31 @@ SETUPTOOLS_BUILD_ARGS ?= "" SETUPTOOLS_SETUP_PATH ?= "${S}" python do_check_backend() { + """ + Check if this package has a pyproject.toml that specifies a PEP517 build backend, so should be + using a different build class. + """ + if "pep517-backend" in (d.getVar("INSANE_SKIP") or "").split(): return - import re + try: + import tomllib + except ImportError: + import bb._vendor.tomli as tomllib + filename = d.expand("${SETUPTOOLS_SETUP_PATH}/pyproject.toml") if os.path.exists(filename): - for line in open(filename): - match = re.match(r"build-backend\s*=\s*\W([\w.]+)\W", line) - if not match: continue + with open(filename, "rb") as f: + toml = tomllib.load(f) - msg = f"inherits setuptools3 but has pyproject.toml with {match[1]}, use the correct class" + try: + backend = toml["build-system"]["build-backend"] + msg = f"inherits setuptools3 but has pyproject.toml specifying backend {backend}, use the correct class" oe.qa.handle_error("pep517-backend", msg, d) - oe.qa.exit_if_errors(d) + oe.qa.exit_if_errors(d) + except KeyError: + return } addtask check_backend after do_patch before do_configure diff --git a/meta/classes-recipe/setuptools3_legacy.bbclass b/meta/classes-recipe/setuptools3_legacy.bbclass index 6b51b9796bc..a70b80cb973 100644 --- a/meta/classes-recipe/setuptools3_legacy.bbclass +++ b/meta/classes-recipe/setuptools3_legacy.bbclass @@ -31,16 +31,31 @@ SETUPTOOLS_PYTHON:class-native = "nativepython3" SETUPTOOLS_SETUP_PATH ?= "${S}" python do_check_backend() { - import re + """ + Check if this package has a pyproject.toml that specifies a PEP517 build backend, so should be + using a different build class. + """ + + if "pep517-backend" in (d.getVar("INSANE_SKIP") or "").split(): + return + + try: + import tomllib + except ImportError: + import bb._vendor.tomli as tomllib + filename = d.expand("${SETUPTOOLS_SETUP_PATH}/pyproject.toml") if os.path.exists(filename): - for line in open(filename): - match = re.match(r"build-backend\s*=\s*\W([\w.]+)\W", line) - if not match: continue + with open(filename, "rb") as f: + toml = tomllib.load(f) - msg = f"inherits setuptools3_legacy but has pyproject.toml with {match[1]}, use the correct class" - if "pep517-backend" not in (d.getVar("INSANE_SKIP") or "").split(): - oe.qa.handle_error("pep517-backend", msg, d) + try: + backend = toml["build-system"]["build-backend"] + msg = f"inherits setuptools3_legacy but has pyproject.toml specifying backend {backend}, use the correct class" + oe.qa.handle_error("pep517-backend", msg, d) + oe.qa.exit_if_errors(d) + except KeyError: + return } addtask check_backend after do_patch before do_configure From patchwork Wed Sep 9 21:55:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 97792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F347C79FBB for ; Wed, 9 Sep 2026 21:55:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.118.1788990942401512518 for ; Wed, 09 Sep 2026 14:55:42 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@arm.com header.s=foss header.b=GCLWG9L0; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34EE71576 for ; Wed, 9 Sep 2026 14:55:38 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 69BC93F7B4 for ; Wed, 9 Sep 2026 14:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1788990941; bh=yjBGZBa7blXwNbve7MVLtRTUp1MLlWqVYVgehnNJc5k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GCLWG9L0PCOIB1HZ+kWrmhv+RbkOPeWLcyTxH30xB1ijkmszXddq7kcBmIfAKf/EZ vy3LndKJsqGeEp/vWy473AAeukbLdsyjFh7thcxmMh0gaF5g1ma9EWEzN9F8u9Nxos Rry9meulUQKN0g2IimK0m7K6kiefR8pNidqNK0jo= From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v2 2/2] classes/cargo-update-recipe-crates: use tomllib directly Date: Wed, 9 Sep 2026 22:55:37 +0100 Message-ID: <20260909215537.51943-2-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260909215537.51943-1-ross.burton@arm.com> References: <20260909215537.51943-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 09 Sep 2026 21:55:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/245519 Now that BitBake vendors in a copy of tomli for when the host Python is too old to support tomllib, we can do the crate update logic directly in the task instead of passing an large inline script to python3-native. The only changes are the removal of nativepython3 and not relying on bitbake's shell expansion to expand variable names. [1] bitbake 69810e0c0a ("lib/bb/_vendor: resync to add tomli") Signed-off-by: Ross Burton --- .../cargo-update-recipe-crates.bbclass | 101 ++++++++++-------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass index 47e845c8221..e62039208c1 100644 --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass @@ -14,7 +14,6 @@ ## To perform the update: bitbake -c update_crates recipe-name addtask do_update_crates after do_patch -do_update_crates[depends] = "python3-native:do_populate_sysroot" do_update_crates[nostamp] = "1" do_update_crates[doc] = "Update the recipe by reading Cargo.lock and write in ${THISDIR}/${BPN}-crates.inc" @@ -23,58 +22,66 @@ RECIPE_UPGRADE_EXTRA_TASKS += "do_update_crates" # The directory where to search for Cargo.lock files CARGO_LOCK_SRC_DIR ??= "${S}" -do_update_crates() { - TARGET_FILE="${THISDIR}/${BPN}-crates.inc" +python do_update_crates() { + cargo_lock_src_dir = d.getVar("CARGO_LOCK_SRC_DIR") - nativepython3 - <