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

fix: pkg_resources deprecated warning #926

Merged

Conversation

SubaruArai
Copy link
Contributor

@SubaruArai SubaruArai commented Aug 7, 2023

This pr fixes a warning caused by pkg_resources, by using importlib.metadata instead.

Importlib.metadata is supported since py3.8, which is shipped with the oldest supported ROS1/2 distro (noetic, Ubuntu 20.04)

Same warning in colcon (maybe resolved)

Use importlib.metadata instead.
src/rosdep2/platforms/pip.py Outdated Show resolved Hide resolved
@SubaruArai
Copy link
Contributor Author

@cottsay I've added importlib_metadata for py3.6.

Couple of questions:

  1. should I change stdeb.cfg and bump the minimum OS and python version? Or should I add importlib_metadata to it?
  2. should we drop setuptools from the dependency? AFAIK, it was added for pkg_resources. Require setuptools, src/rosdep2/platforms/pip.py imports pkg_resources #809

@SubaruArai
Copy link
Contributor Author

@cottsay ping

@cottsay
Copy link
Member

cottsay commented Aug 16, 2023

Good questions.

  1. should I change stdeb.cfg and bump the minimum OS and python version? Or should I add importlib_metadata to it?

Should be safe to add python3 (>= 3.8) | python3-importlib-metadata as a dependency to the stdeb.cfg like this.

  1. should we drop setuptools from the dependency? AFAIK, it was added for pkg_resources. Require setuptools, src/rosdep2/platforms/pip.py imports pkg_resources #809

Yes, please do. Both setup.cfg and stdeb.cfg reference it.

@SubaruArai SubaruArai requested a review from cottsay August 17, 2023 00:29
@SubaruArai
Copy link
Contributor Author

@cottsay Couple of comments / questions (they'll be in their own pr if they need to be addressed)

  1. I left get_version_strings's output as setuptools x.y.z, for backwards compatibility. Or should I change it?
  2. stdeb.cfg contains python2 related config. Should we delete it like in colcon-core?
  3. the ci file contains python2 tests. Should we delete it?

@cottsay
Copy link
Member

cottsay commented Aug 17, 2023

Thanks for iterating.

  1. I left get_version_strings's output as setuptools x.y.z, for backwards compatibility. Or should I change it?

I think it's good as-is. The setuptools version is useful here not because we're using setuptools (pkg_resources) to get the information, but because at the time, the packages used setuptools to build. While there are more options now and pip supports them, setuptools is still widely used and could be useful information debugging things.

  1. stdeb.cfg contains python2 related config. Should we delete it like in colcon-core?
  2. the ci file contains python2 tests. Should we delete it?

These need to be separate changes for sure, and I think they should be made prior to merging this change so that we can point to the exact moment we dropped Python 2 support from rosdep. I've started this process in catkin_pkg, and there will likely be a bit more to it than changing ci.yaml and stdeb.cfg. Can you give me a few days to work through that process?

@SubaruArai
Copy link
Contributor Author

Ping me once it's merged, I'll fix merge conflicts. (if any)

@cottsay
Copy link
Member

cottsay commented Apr 10, 2024

Can we add a simple test to exercise this code? Something like this could be added to test_rosdep_pip.py:

def test_PipInstaller_get_version_strings():
    from rosdep2.platforms.pip import PipInstaller
    installer = PipInstaller()
    assert installer.get_version_strings()

@SubaruArai
Copy link
Contributor Author

@cottsay Done!

Copy link
Member

@cottsay cottsay left a comment

Choose a reason for hiding this comment

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

Thanks for iterating

@cottsay cottsay merged commit 3481576 into ros-infrastructure:master Apr 11, 2024
15 checks passed
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.

2 participants