From 78a3943b752afa9321bd4d87626cf44b5fdeeb63 Mon Sep 17 00:00:00 2001
From: Oliver Smith <ollieparanoid@postmarketos.org>
Date: Sun, 31 May 2026 10:51:08 +0200
Subject: [PATCH] python 3.13: binman: migrate from pkg_resources to importlib

Fix for:
    File "/home/pmos/build/src/uboot-imx-c4960dade272da9d6a7f53f6956d4d6747d573e9/tools/binman/control.py", line 11, in <module>
      import pkg_resources
  ModuleNotFoundError: No module named 'pkg_resources'

Patch based on:
https://github.com/u-boot/u-boot/commit/538719cb6a77934d069e0e64f264457a59a9ebfc

Signed-off-by: Oliver Smith <ollieparanoid@postmarketos.org>
---
 tools/binman/control.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index bfe63a1520..e77e433ae4 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -8,7 +8,7 @@
 from collections import OrderedDict
 import glob
 import os
-import pkg_resources
+import importlib.resources as importlib_resources
 import re
 
 import sys
@@ -89,7 +89,7 @@ def _ReadMissingBlobHelp():
             msg = ''
         return tag, msg
 
-    my_data = pkg_resources.resource_string(__name__, 'missing-blob-help')
+    my_data = importlib_resources.files(__package__).joinpath('missing-blob-help').read_bytes()
     re_tag = re.compile('^([-a-z0-9]+):$')
     result = {}
     tag = None
@@ -136,8 +136,9 @@ def GetEntryModules(include_testing=True):
     Returns:
         Set of paths to entry class filenames
     """
-    glob_list = pkg_resources.resource_listdir(__name__, 'etype')
-    glob_list = [fname for fname in glob_list if fname.endswith('.py')]
+    entries = importlib_resources.files(__package__).joinpath('etype')
+    glob_list = [entry.name for entry in entries.iterdir()
+                 if entry.name.endswith('.py') and entry.is_file()]
     return set([os.path.splitext(os.path.basename(item))[0]
                 for item in glob_list
                 if include_testing or '_testing' not in item])
-- 
2.54.0

