new file mode 100644
@@ -0,0 +1,27 @@
+From ef33ac27e3ac1b9cb159d7eec0ad1af120cd9dc1 Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@arm.com>
+Date: Fri, 17 Apr 2026 16:53:42 +0100
+Subject: [PATCH] prefer valid entrypoints
+
+When there are multiple distributions found and some of them are invalid, ensure that
+the entry_points() accessor puts valid dists first.
+
+Upstream-Status: Submitted [https://github.com/python/importlib_metadata/issues/534]
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ Lib/importlib/metadata/__init__.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Lib/importlib/metadata/__init__.py b/Lib/importlib/metadata/__init__.py
+index 085378c..ff5cae4 100644
+--- a/Lib/importlib/metadata/__init__.py
++++ b/Lib/importlib/metadata/__init__.py
+@@ -1016,7 +1016,7 @@ def entry_points(**params) -> EntryPoints:
+ :return: EntryPoints for all installed packages.
+ """
+ eps = itertools.chain.from_iterable(
+- dist.entry_points for dist in _unique(distributions())
++ dist.entry_points for dist in _unique(Distribution._prefer_valid(distributions()))
+ )
+ return EntryPoints(eps).select(**params)
+
@@ -34,6 +34,7 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
file://0001-test_sysconfig-skip-test_sysconfig.test_sysconfigdat.patch \
file://0001-Skip-flaky-test_default_timeout-tests.patch \
file://0001-test_only_active_thread-skip-problematic-test.patch \
+ file://0001-prefer-valid-entrypoints.patch \
"
SRC_URI:append:class-native = " \
file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \
When bitbake regenerates a sysroot due to upgrades it will remove any previously installed files but keep the directories. This can result in site-packages containing: setuptools/ <-- the actual Python code setuptools-82.0.0.dist-info <-- empty metadata directory setuptools-82.0.1.dist-info <-- populated metadata directory When importlib_metadata.entry_points() iterates the distributions it will take the list of dists *in on-disk order* and then remove duplicates. If the empty directory comes first in the unsorted directory listing then that is the only one that is returned. This eventually results in mysterious errors from setuptools: error: invalid command 'egg_info' Solve this by sorting the distribution list so that valid dists are first. [ YOCTO #16235 ] Signed-off-by: Ross Burton <ross.burton@arm.com> --- .../0001-prefer-valid-entrypoints.patch | 27 +++++++++++++++++++ .../recipes-devtools/python/python3_3.14.4.bb | 1 + 2 files changed, 28 insertions(+) create mode 100644 meta/recipes-devtools/python/python3/0001-prefer-valid-entrypoints.patch