Skip to content
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

Replace pkg_resources by importlib.metadata #766

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

MatthijsBurgh
Copy link
Contributor

pkg_resources is deprecated and was causing issues in finding dependencies of catkin_tools_document.

I replaced it by importlib.metadata. I am not 100% sure the changes in catkin_tools/metadata.py are correct.

The call on entry_points() is expensive, therefore I added a private function in combination with a global variable. I only applied this in the commands/catkin.py. Ideally this is shared between files. Please let me know when you have suggestion to it a bit more cleanly and share it between the files.

@@ -184,7 +196,7 @@ def catkin_main(sysargs):
# Check for version
if '--version' in sysargs:
print('catkin_tools {} (C) 2014-{} Open Source Robotics Foundation'.format(
pkg_resources.get_distribution('catkin_tools').version,
distribution('catkin_tools').version,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's importlib.metadata.version as a shortcut for this

@graingert
Copy link

I have a PR that fixes the deprecation warnings: #767

@MatthijsBurgh
Copy link
Contributor Author

So the select isn't available on 3.8 and 3.9..

I wil fix it later. And maybe #767 is better. But it lacks the single call to entry_points for now.

@graingert
Copy link

But it lacks the single call to entry_points for now.

It uses functools.lru_cache to do a single call

@timonegk
Copy link
Member

timonegk commented Sep 4, 2023

But it lacks the single call to entry_points for now.

It uses functools.lru_cache to do a single call

But only for the verb entry points, in this PR there is a single call to entry_points for all groups combined

@MatthijsBurgh
Copy link
Contributor Author

This PR also does multiple calls for now. But we should combine the code regarding it of this PR and #767

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

Successfully merging this pull request may close these issues.

3 participants