Skip to content

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 12, 2025

Each time we run pytest in our GitHub Actions, we get the warning:

  /home/runner/work/pymavlink/pymavlink/tests/test_mavlogdump.py:9:
   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.
    import pkg_resources

https://setuptools.pypa.io/en/latest/pkg_resources.html

Use here = pathlib.Path(__file__).parent to replace pkg_resources.resource_filename(__name__, xxx).

How is this tested?

All modified files are run by pytest in our GitHub Actions.

@cclauss cclauss force-pushed the remove-deprecated_pkg_resources branch 3 times, most recently from dfe43fc to e986634 Compare July 13, 2025 19:52
Each time we run pytest in our GitHub Actions, we get the warning:
```tests/test_mavlogdump.py:9
  /home/runner/work/pymavlink/pymavlink/tests/test_mavlogdump.py:9:
   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.
    import pkg_resources
```
Use `here = pathlib.Path(__file__).parent` to replace `pkg_resources.resource_filename(__name__, xxx)`.

All modified files are run by pytest in our GitHub Actions.
@cclauss cclauss force-pushed the remove-deprecated_pkg_resources branch from e986634 to dbceb85 Compare July 13, 2025 19:54
@amilcarlucas
Copy link
Contributor

Nice cleanup


import unittest
import pkg_resources
from pathlib import Path
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from pathlib import Path
import pathlib

and namespace the creation of the object

test_filename = "64-fields.xml"
test_filepath = pkg_resources.resource_filename(__name__,
test_filename)
test_filepath = str(here / "64-fields.xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this equivalent to what we did have? ie. this looks like it's trying to take out of an installed package space if that's where you currently are. It's very weird if that's not the case as you wouldn't need to use pkg_resources

@cclauss cclauss marked this pull request as draft July 15, 2025 10:10
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