Skip to content

Commit 88d39a5

Browse files
committed
Refactor changelog entries and update import statements to use importlib.resources
1 parent eac3ed4 commit 88d39a5

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Changed
1212
- `%traceback` setting default value is now `True` to show traceback in message log
13-
- serializer is now more permissive for iris objects, allowing iris object type of `%Persistent` and `%Stream` to support http inbound/outbound adapters
13+
- serializer is now more permissive for iris objects, allowing iris object type of `%Stream` to support http inbound/outbound adapters
14+
- remove usage of `pkg_resources` in favor of `importlib.resources`
1415

1516
### Fixed
1617

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ dependencies = [
3030
"pydantic>=2.0.0",
3131
"xmltodict>=0.12.0",
3232
"iris-embedded-python-wrapper>=0.0.6",
33-
"setuptools>=40.8.0",
3433
"jsonpath-ng>=1.7.0",
3534
"debugpy>=1.8.0",
3635
]

src/iop/_utils.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from . import _iris
55
import inspect
66
import xmltodict
7-
import pkg_resources
87
import importlib
98
import importlib.util
9+
import importlib.resources
1010
import json
1111
from iop._message import _Message, _PydanticMessage
1212
from pydantic import TypeAdapter
@@ -26,13 +26,22 @@ def raise_on_error(sc):
2626
def setup(path:str = None):
2727

2828
if path is None:
29-
# get the path of the data folder with pkg_resources
30-
path = pkg_resources.resource_filename('iop', 'cls')
29+
# get the path of the data folder with importlib.resources
30+
try:
31+
path = importlib.resources.files('iop').joinpath('cls')
32+
path = str(path)
33+
except ModuleNotFoundError:
34+
path = None
3135

32-
_Utils.raise_on_error(_iris.get_iris().cls('%SYSTEM.OBJ').LoadDir(path,'cubk',"*.cls",1))
36+
if path:
37+
_Utils.raise_on_error(_iris.get_iris().cls('%SYSTEM.OBJ').LoadDir(path,'cubk',"*.cls",1))
3338

3439
# for retrocompatibility load grongier.pex
35-
path = pkg_resources.resource_filename('grongier', 'cls')
40+
try:
41+
path = importlib.resources.files('grongier').joinpath('cls')
42+
path = str(path)
43+
except ModuleNotFoundError:
44+
path = None
3645

3746
if path:
3847
_Utils.raise_on_error(_iris.get_iris().cls('%SYSTEM.OBJ').LoadDir(path,'cubk',"*.cls",1))

0 commit comments

Comments
 (0)