Skip to content

Commit

Permalink
Remove use of pkg_resources (#1058)
Browse files Browse the repository at this point in the history
* Clean resource filename

* Remove use of pkg_resources
  • Loading branch information
MartinHjelmare authored Dec 27, 2024
1 parent d0be60e commit 4415da5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions camacq/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Handle the config file."""

from importlib import resources
import logging
import os
from pathlib import Path

from pkg_resources import resource_filename
from ruamel.yaml import YAML, YAMLError

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -89,7 +89,7 @@ def create_default_config(config_dir):
failed.
"""
config_path = config_dir / YAML_CONFIG_FILE
default_config_template = resource_filename(__name__, DEFAULT_CONFIG_TEMPLATE)
default_config_template = resources.files(__package__) / DEFAULT_CONFIG_TEMPLATE
data = load_config_file(Path(default_config_template))
yaml = YAML()

Expand Down
4 changes: 2 additions & 2 deletions camacq/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio

import pkg_resources
from importlib.metadata import entry_points

from camacq.helper import setup_one_module

Expand Down Expand Up @@ -46,6 +46,6 @@ def get_plugins():
"""Return a dict of plugin modules."""
plugins = {
entry_point.name: entry_point.load()
for entry_point in pkg_resources.iter_entry_points("camacq.plugins")
for entry_point in entry_points(group="camacq.plugins")
}
return plugins
4 changes: 2 additions & 2 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Test a complete workflow."""

from importlib import resources
import logging
from functools import partial
from pathlib import Path
from unittest.mock import Mock, call, patch

import pytest
from leicacam.async_cam import AsyncCAM
from pkg_resources import resource_filename

from camacq import bootstrap
from camacq.config import DEFAULT_CONFIG_TEMPLATE, load_config_file
Expand Down Expand Up @@ -66,7 +66,7 @@ async def test_workflow(center, caplog, api, rename_image):
"""Test a complete workflow."""
# pylint: disable=too-many-locals,too-many-statements
caplog.set_level(logging.DEBUG)
config_path = Path(resource_filename(bootstrap.__name__, DEFAULT_CONFIG_TEMPLATE))
config_path = resources.files(bootstrap.__package__) / DEFAULT_CONFIG_TEMPLATE
config = await center.add_executor_job(load_config_file, config_path)
config.pop("logging")
await bootstrap.setup_dict(center, config)
Expand Down

0 comments on commit 4415da5

Please sign in to comment.