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

python3.12 support #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

python3.12 support #73

wants to merge 1 commit into from

Conversation

sirtoobii
Copy link

Use importlib.resources instead of the deprecated pkg_resources.

The load_dsdl() step fails on Python3.12 since pkg_resources is being depreciated. This PR implements using the newer importlib.resources.files method to get the dsdl_path while still allowing to fallback to the older pkg_resources approach.

Error message when running the "dump all" example (without this PR, Ubuntu 22.04)
DSDL load exception: No module named 'pkg_resources'
Traceback (most recent call last):
  File "/home/tobias/Documents/sw-rid-beacon/main.py", line 6, in <module>
    import dronecan, time, math
  File "/home/tobias/Documents/sw-rid-beacon/venv/lib/python3.12/site-packages/dronecan/__init__.py", line 226, in <module>
    import dronecan.app as app
  File "/home/tobias/Documents/sw-rid-beacon/venv/lib/python3.12/site-packages/dronecan/app/__init__.py", line 12, in <module>
    from . import dynamic_node_id
  File "/home/tobias/Documents/sw-rid-beacon/venv/lib/python3.12/site-packages/dronecan/app/dynamic_node_id.py", line 25, in <module>
    class CentralizedServer(object):
  File "/home/tobias/Documents/sw-rid-beacon/venv/lib/python3.12/site-packages/dronecan/app/dynamic_node_id.py", line 26, in CentralizedServer
    QUERY_TIMEOUT = uavcan.protocol.dynamic_node_id.Allocation().FOLLOWUP_TIMEOUT_MS / 1000  # @UndefinedVariable
                    ^^^^^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'protocol'

Use importlib.resources instead of the deprecated pkg_resources.
@davidbuzz
Copy link
Member

does this still work in older python/s?

@sirtoobii
Copy link
Author

Yes, I was however only able to test it with 3.9 as I have currently no easy access to older versions

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