Skip to content

Commit b20f7da

Browse files
authored
Revert "Remove pkg_resources dependency" and test Python 3.12 (#183)
* Revert "Remove dependency on pkg_resources in favour of importlib (#181)" This ran into the python 3.8/3.10/3.12 cross-compatibility issue. * Add python 3.12 to azure testing This should avoid this problem happening again (and github actions should now run properly).
1 parent 0f0f9e8 commit b20f7da

File tree

5 files changed

+14
-30
lines changed

5 files changed

+14
-30
lines changed

.azure-pipelines/azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,7 @@ stages:
8888
PYTHON_VERSION: 3.10
8989
python311:
9090
PYTHON_VERSION: 3.11
91+
python312:
92+
PYTHON_VERSION: 3.12
9193
steps:
9294
- template: ci.yml

src/workflows/services/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from importlib.metadata import entry_points
3+
import pkg_resources
44

55

66
def lookup(service: str):
@@ -25,7 +25,10 @@ def get_known_services():
2525
setattr(
2626
get_known_services,
2727
"cache",
28-
{e.name: e.load for e in entry_points()["workflows.services"]},
28+
{
29+
e.name: e.load
30+
for e in pkg_resources.iter_entry_points("workflows.services")
31+
},
2932
)
3033
register = get_known_services.cache.copy()
3134
return register

src/workflows/transport/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import argparse
44
import optparse
5-
from importlib.metadata import entry_points
65
from typing import TYPE_CHECKING, Type
76

7+
import pkg_resources
8+
89
if TYPE_CHECKING:
910
from .common_transport import CommonTransport
1011

@@ -60,6 +61,9 @@ def get_known_transports() -> dict[str, Type[CommonTransport]]:
6061
setattr(
6162
get_known_transports,
6263
"cache",
63-
{e.name: e.load() for e in entry_points()["workflows.transport"]},
64+
{
65+
e.name: e.load()
66+
for e in pkg_resources.iter_entry_points("workflows.transport")
67+
},
6468
)
6569
return get_known_transports.cache.copy() # type: ignore

tests/services/test.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
from __future__ import annotations
22

33
import workflows.services
4-
from workflows.services.common_service import CommonService
54

65

76
def test_known_services_is_a_dictionary():
87
"""Check services register build in CommonService."""
98
assert isinstance(workflows.services.get_known_services(), dict)
10-
11-
12-
def test_enumerate_services():
13-
"""Verify we can discover the installed services."""
14-
services = workflows.services.get_known_services()
15-
assert services.keys() == {
16-
"SampleConsumer",
17-
"SampleProducer",
18-
"SampleTxn",
19-
"SampleTxnProducer",
20-
}
21-
assert all([issubclass(service(), CommonService) for service in services.values()])

tests/transport/test.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
from __future__ import annotations
22

33
import workflows.transport
4-
from workflows.transport.common_transport import CommonTransport
54

65

76
def test_known_transports_is_a_dictionary():
87
"""Check transport register build in CommonTransport."""
9-
transports = workflows.transport.get_known_transports()
10-
print(transports)
11-
assert isinstance(transports, dict)
12-
13-
14-
def test_enumerate_transports():
15-
"""Verify we can discover the installed transports."""
16-
transports = workflows.transport.get_known_transports()
17-
assert transports.keys() == {"OfflineTransport", "PikaTransport", "StompTransport"}
18-
assert all(
19-
[issubclass(transport, CommonTransport) for transport in transports.values()]
20-
)
8+
assert isinstance(workflows.transport.get_known_transports(), dict)
219

2210

2311
def test_load_any_transport():

0 commit comments

Comments
 (0)