[PATCH] tools: Fall back to importlib_resources on Python 3.6
Jan Kiszka
jan.kiszka at siemens.com
Sat Apr 22 16:42:48 CEST 2023
From: Jan Kiszka <jan.kiszka at siemens.com>
importlib.resources became part of 3.7 only. Allow using distros with
3.6 and the importlib_resources backport.
Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
---
Tested on OpenSUSE 15.4 with importlib_resources 1.1.0.
tools/binman/control.py | 6 +++++-
tools/buildman/control.py | 6 +++++-
tools/patman/__main__.py | 6 +++++-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 0febcb79a60..68597c4e779 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -7,7 +7,11 @@
from collections import OrderedDict
import glob
-import importlib.resources
+try:
+ import importlib.resources
+except ImportError:
+ # for Python 3.6
+ import importlib_resources
import os
import pkg_resources
import re
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 35f44c0cf3d..09a11f25b3f 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -3,7 +3,11 @@
#
import multiprocessing
-import importlib.resources
+try:
+ import importlib.resources
+except ImportError:
+ # for Python 3.6
+ import importlib_resources
import os
import shutil
import subprocess
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 48ffbc8eadf..8eba5d34864 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -7,7 +7,11 @@
"""See README for more information"""
from argparse import ArgumentParser
-import importlib.resources
+try:
+ import importlib.resources
+except ImportError:
+ # for Python 3.6
+ import importlib_resources
import os
import re
import sys
--
2.35.3
More information about the U-Boot
mailing list