| 1 |
From: Alexandre Detiste <[email protected]> |
| 2 |
Date: Sat, 21 Mar 2026 13:38:07 +0100 |
| 3 |
Subject: Patch out usage of importlib_resources |
| 4 |
|
| 5 |
Bug-Debian: https://bugs.debian.org/1111880 |
| 6 |
Forwarded: not-needed |
| 7 |
Reviewed-By: Jakob Haufe <[email protected]> |
| 8 |
Last-Update: 2025-11-08 |
| 9 |
--- |
| 10 |
pyocd/debug/sequences/default_sequences.py | 4 ++-- |
| 11 |
pyocd/debug/svd/loader.py | 4 ++-- |
| 12 |
setup.cfg | 1 - |
| 13 |
3 files changed, 4 insertions(+), 5 deletions(-) |
| 14 |
|
| 15 |
diff --git a/pyocd/debug/sequences/default_sequences.py b/pyocd/debug/sequences/default_sequences.py |
| 16 |
index a4dbd5a..07ad29b 100644 |
| 17 |
--- a/pyocd/debug/sequences/default_sequences.py |
| 18 |
+++ b/pyocd/debug/sequences/default_sequences.py |
| 19 |
@@ -14,7 +14,7 @@ |
| 20 |
# See the License for the specific language governing permissions and |
| 21 |
# limitations under the License. |
| 22 |
|
| 23 |
|
| 24 |
+import importlib.resources |
| 25 |
import logging |
| 26 |
import yaml |
| 27 |
|
| 28 |
@@ -105,7 +105,7 @@ class DefaultDebugSequences(_YAMLSequenceParser): |
| 29 |
def _load_default_sequences(cls) -> FrozenSet[DebugSequence]: |
| 30 |
"""Load default sequences from YAML file.""" |
| 31 |
try: |
| 32 |
|
| 33 |
+ resource_path = importlib.resources.files('pyocd.debug.sequences') / 'default_sequences.yaml' |
| 34 |
with resource_path.open('r') as f: |
| 35 |
yaml_data = yaml.safe_load(f) or {} |
| 36 |
except FileNotFoundError: |
| 37 |
diff --git a/pyocd/debug/svd/loader.py b/pyocd/debug/svd/loader.py |
| 38 |
index ee58f1e..39a1e7f 100644 |
| 39 |
--- a/pyocd/debug/svd/loader.py |
| 40 |
+++ b/pyocd/debug/svd/loader.py |
| 41 |
@@ -17,7 +17,7 @@ |
| 42 |
|
| 43 |
import threading |
| 44 |
import logging |
| 45 |
|
| 46 |
+import importlib.resources |
| 47 |
import zipfile |
| 48 |
|
| 49 |
from .parser import SVDParser |
| 50 |
@@ -31,7 +31,7 @@ class SVDFile(object): |
| 51 |
@classmethod |
| 52 |
def from_builtin(cls, svd_name): |
| 53 |
try: |
| 54 |
|
| 55 |
+ zip_ref = importlib.resources.files("pyocd").joinpath(BUILTIN_SVD_DATA_PATH) |
| 56 |
zip_stream = zip_ref.open('rb') |
| 57 |
zip = zipfile.ZipFile(zip_stream, 'r') |
| 58 |
return SVDFile(zip.open(svd_name)) |
| 59 |
diff --git a/setup.cfg b/setup.cfg |
| 60 |
index 07f40b1..254f7dd 100644 |
| 61 |
--- a/setup.cfg |
| 62 |
+++ b/setup.cfg |
| 63 |
@@ -56,7 +56,6 @@ install_requires = |
| 64 |
colorama<1.0 |
| 65 |
hidapi>=0.10.1,<1.0; platform_system != "Linux" |
| 66 |
importlib_metadata>=3.6 |
| 67 |
|
| 68 |
intelhex>=2.0,<3.0 |
| 69 |
intervaltree>=3.0.2,<4.0 |
| 70 |
lark>=1.1.5,<2.0 |