diff --git a/.ci/scripts/collect_changes.py b/.ci/scripts/collect_changes.py index d11b52874..94fbfd2c2 100755 --- a/.ci/scripts/collect_changes.py +++ b/.ci/scripts/collect_changes.py @@ -4,7 +4,7 @@ import toml from git import GitCommandError, Repo -from pkg_resources import parse_version +from packaging.version import parse as parse_version # Read Towncrier settings tc_settings = toml.load("pyproject.toml")["tool"]["towncrier"] diff --git a/.github/workflows/collect_changes.yml b/.github/workflows/collect_changes.yml index 2cf813c57..128b4c547 100644 --- a/.github/workflows/collect_changes.yml +++ b/.github/workflows/collect_changes.yml @@ -20,7 +20,7 @@ jobs: git config user.email pulp-infra@redhat.com - name: Collect changes run: | - pip install GitPython toml + pip install GitPython packaging toml python3 .ci/scripts/collect_changes.py - name: Create Pull Request uses: peter-evans/create-pull-request@v5 diff --git a/CHANGES/865.bugfix b/CHANGES/865.bugfix new file mode 100644 index 000000000..21495ab66 --- /dev/null +++ b/CHANGES/865.bugfix @@ -0,0 +1 @@ +Remove dependency on `pkg_resources` that failed some installations but is deprecated anyway. diff --git a/pulp-glue/pulp_glue/common/i18n.py b/pulp-glue/pulp_glue/common/i18n.py index 063356ed5..021dcdf30 100644 --- a/pulp-glue/pulp_glue/common/i18n.py +++ b/pulp-glue/pulp_glue/common/i18n.py @@ -1,9 +1,15 @@ import gettext +import sys from functools import lru_cache -import pkg_resources +if sys.version_info >= (3, 9): + from importlib.resources import files +else: + from importlib_resources import files +# Need to call lru_cache() before using it as a decorator for python 3.7 compatibility +@lru_cache(maxsize=None) def get_translation(name: str) -> gettext.NullTranslations: """ Return a translations object for a certain import path. @@ -23,11 +29,5 @@ def get_translation(name: str) -> gettext.NullTranslations: _ = translation.gettext ``` """ - localedir = pkg_resources.resource_filename(name, "locale") - return _get_translation_for_domain("messages", localedir) - - -# Need to call lru_cache() before using it as a decorator for python 3.7 compatibility -@lru_cache(maxsize=None) -def _get_translation_for_domain(domain: str, localedir: str) -> gettext.NullTranslations: - return gettext.translation(domain, localedir=localedir, fallback=True) + localedir = files(name) / "locale" + return gettext.translation("messages", localedir=str(localedir), fallback=True) diff --git a/pulp-glue/pyproject.toml b/pulp-glue/pyproject.toml index debc9724a..57b28b742 100644 --- a/pulp-glue/pyproject.toml +++ b/pulp-glue/pyproject.toml @@ -13,18 +13,19 @@ authors = [ {name = "Pulp Team", email = "pulp-list@redhat.com"}, ] classifiers = [ - "Development Status :: 4 - Beta", - "Environment :: Other Environment", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Topic :: System :: Software Distribution", - "Typing :: Typed", + "Development Status :: 4 - Beta", + "Environment :: Other Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: System :: Software Distribution", + "Typing :: Typed", ] dependencies = [ - "packaging>=20.0,<24", - "requests>=2.24.0,<2.32", + "packaging>=20.0,<24", + "requests>=2.24.0,<2.32", + "importlib_resources>=5.7,<6.2;python_version<'3.9'", ] [project.urls] diff --git a/pulp_cli/__init__.py b/pulp_cli/__init__.py index 6c234a57f..b8830bb8b 100644 --- a/pulp_cli/__init__.py +++ b/pulp_cli/__init__.py @@ -1,8 +1,13 @@ +import sys from types import ModuleType from typing import Any, Dict, Optional import click -import pkg_resources + +if sys.version_info >= (3, 10): + from importlib.metadata import entry_points +else: + from importlib_metadata import entry_points __version__ = "0.23.0.dev" _main: Optional[click.Group] = None @@ -16,7 +21,7 @@ def load_plugins() -> click.Group: # https://packaging.python.org/guides/creating-and-discovering-plugins/#using-package-metadata discovered_plugins: Dict[str, ModuleType] = { entry_point.name: entry_point.load() - for entry_point in pkg_resources.iter_entry_points("pulp_cli.plugins") + for entry_point in entry_points(group="pulp_cli.plugins") } _main = discovered_plugins["common"].main assert isinstance(_main, click.Group) diff --git a/pyproject.toml b/pyproject.toml index 182714517..6e43a81e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ dependencies = [ "PyYAML>=5.3,<6.1", "schema>=0.7.5,<0.8", "toml>=0.10.2,<0.11", + "importlib_metadata>=4.8,<7.1;python_version<'3.10'", ] [project.optional-dependencies]