Skip to content

Commit

Permalink
Revert "Remove pkg_resources dependency" and test Python 3.12 (#183)
Browse files Browse the repository at this point in the history
* 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).
  • Loading branch information
ndevenish authored Sep 13, 2024
1 parent 0f0f9e8 commit b20f7da
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,7 @@ stages:
PYTHON_VERSION: 3.10
python311:
PYTHON_VERSION: 3.11
python312:
PYTHON_VERSION: 3.12
steps:
- template: ci.yml
7 changes: 5 additions & 2 deletions src/workflows/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from importlib.metadata import entry_points
import pkg_resources


def lookup(service: str):
Expand All @@ -25,7 +25,10 @@ def get_known_services():
setattr(
get_known_services,
"cache",
{e.name: e.load for e in entry_points()["workflows.services"]},
{
e.name: e.load
for e in pkg_resources.iter_entry_points("workflows.services")
},
)
register = get_known_services.cache.copy()
return register
8 changes: 6 additions & 2 deletions src/workflows/transport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import argparse
import optparse
from importlib.metadata import entry_points
from typing import TYPE_CHECKING, Type

import pkg_resources

if TYPE_CHECKING:
from .common_transport import CommonTransport

Expand Down Expand Up @@ -60,6 +61,9 @@ def get_known_transports() -> dict[str, Type[CommonTransport]]:
setattr(
get_known_transports,
"cache",
{e.name: e.load() for e in entry_points()["workflows.transport"]},
{
e.name: e.load()
for e in pkg_resources.iter_entry_points("workflows.transport")
},
)
return get_known_transports.cache.copy() # type: ignore
13 changes: 0 additions & 13 deletions tests/services/test.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
from __future__ import annotations

import workflows.services
from workflows.services.common_service import CommonService


def test_known_services_is_a_dictionary():
"""Check services register build in CommonService."""
assert isinstance(workflows.services.get_known_services(), dict)


def test_enumerate_services():
"""Verify we can discover the installed services."""
services = workflows.services.get_known_services()
assert services.keys() == {
"SampleConsumer",
"SampleProducer",
"SampleTxn",
"SampleTxnProducer",
}
assert all([issubclass(service(), CommonService) for service in services.values()])
14 changes: 1 addition & 13 deletions tests/transport/test.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
from __future__ import annotations

import workflows.transport
from workflows.transport.common_transport import CommonTransport


def test_known_transports_is_a_dictionary():
"""Check transport register build in CommonTransport."""
transports = workflows.transport.get_known_transports()
print(transports)
assert isinstance(transports, dict)


def test_enumerate_transports():
"""Verify we can discover the installed transports."""
transports = workflows.transport.get_known_transports()
assert transports.keys() == {"OfflineTransport", "PikaTransport", "StompTransport"}
assert all(
[issubclass(transport, CommonTransport) for transport in transports.values()]
)
assert isinstance(workflows.transport.get_known_transports(), dict)


def test_load_any_transport():
Expand Down

0 comments on commit b20f7da

Please sign in to comment.