Skip to content

Replace usage of pkg_resources.iter_entry_points, update exception message #8992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 30, 2025

Conversation

amercader
Copy link
Member

pkg_resources is deprecated and to be removed soon, replace it with importlib.metadata instead. :

UserWarning: pkg_resources is deprecated as an API. See
https://setuptools.pypa.io/en/latest/pkg_resources.html. The
pkg_resources package is slated for removal as early as 2025-11-30.
Refrain from using this package or pin to Setuptools<81.

While working on that code, I never liked this exception message when trying to load an non-existent plugin:

  File "/home/adria/dev/projects/ckan-py310/ckan/ckan/plugins/core.py", line 250, in _get_service
    raise PluginNotFoundException(plugin_name)
ckan.plugins.base.PluginNotFoundException: Interface dcat does not exist

So I updated the message:

  File "/home/adria/dev/projects/ckan-py310/ckan/ckan/plugins/core.py", line 250, in _get_service
    raise PluginNotFoundException(plugin_name)
ckan.plugins.base.PluginNotFoundException: Plugin 'dcat' not found.

Did you install the 'ckanext-*' Python package that contains the plugin?

It is deprecated and to be removed soon:

```
UserWarning: pkg_resources is deprecated as an API. See
https://setuptools.pypa.io/en/latest/pkg_resources.html. The
pkg_resources package is slated for removal as early as 2025-11-30.
Refrain from using this package or pin to Setuptools<81.
```

Use `importlib.metadata` instead.
@amercader
Copy link
Member Author

The changes are not compatible with Python 3.9. Waiting on #8994 to update the workflows

Not a fan of doing these but the calls are correct according to the docs

https://docs.python.org/3.10/library/importlib.metadata.html#entry-points
amercader added a commit that referenced this pull request Jun 12, 2025
@amercader
Copy link
Member Author

Typing errors will be fixed when #8995 is merged

@amercader amercader self-assigned this Jun 23, 2025
@amercader amercader marked this pull request as ready for review June 23, 2025 10:27
Copy link

codecov bot commented Jun 27, 2025

❌ Unsupported file format

Upload processing failed due to unsupported file format. Please review the parser error message:
Error deserializing json

Caused by:
expected value at line 1 column 1

For more help, visit our troubleshooting guide.

@amercader amercader assigned wardi and unassigned amercader Jun 30, 2025
@amercader
Copy link
Member Author

@wardi Not sure what codecov is going on about, but this is ready to go

@wardi wardi merged commit d78210d into master Jun 30, 2025
43 of 45 checks passed
@wardi wardi deleted the update-iter-entry-points branch June 30, 2025 13:22
@ckanbot
Copy link

ckanbot commented Jun 30, 2025

Backport failed for dev-v2.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dev-v2.11
git worktree add -d .worktree/backport-8992-to-dev-v2.11 origin/dev-v2.11
cd .worktree/backport-8992-to-dev-v2.11
git switch --create backport-8992-to-dev-v2.11
git cherry-pick -x e17ff328c87c3967c1f2aa2be8199ce4c44c92b9 6a1a513a13e3d89b84084ddd29926d8b83b97cf6 7c0c04b2ccc10f462b4979b50c225edd930ae1b2 beb3ba6845158fa5dd82b81a1d3eddd292fd8ae1 b81cac761585ca0860ebcb3df2b60a5e852a3fba 8d037744f0a842fd0247926804ebd5cb7bd85298

@ckanbot
Copy link

ckanbot commented Jun 30, 2025

Backport failed for dev-v2.10, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dev-v2.10
git worktree add -d .worktree/backport-8992-to-dev-v2.10 origin/dev-v2.10
cd .worktree/backport-8992-to-dev-v2.10
git switch --create backport-8992-to-dev-v2.10
git cherry-pick -x e17ff328c87c3967c1f2aa2be8199ce4c44c92b9 6a1a513a13e3d89b84084ddd29926d8b83b97cf6 7c0c04b2ccc10f462b4979b50c225edd930ae1b2 beb3ba6845158fa5dd82b81a1d3eddd292fd8ae1 b81cac761585ca0860ebcb3df2b60a5e852a3fba 8d037744f0a842fd0247926804ebd5cb7bd85298

@amercader
Copy link
Member Author

2.11 version is here: #9013. On 2.10 the plugins code was too different to apply the patches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants