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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions dronecan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
import os
import sys
import struct
import pkg_resources
try:
# pkg_resources is depreciated in favor of importlib.resources.*
# https://setuptools.pypa.io/en/latest/pkg_resources.html
from importlib.resources import files as importlib_files
USE_FALLBACK_PGK_RES = False
except ImportError:
# Only necessary in Python versions < 3.7
USE_FALLBACK_PGK_RES = True
import pkg_resources
import time
from logging import getLogger

Expand Down Expand Up @@ -124,7 +132,10 @@ def load_dsdl(*paths, **args):
# noinspection PyBroadException
try:
if not args.get("exclude_dist", None):
dsdl_path = pkg_resources.resource_filename(__name__, "dsdl_specs") # @UndefinedVariable
if USE_FALLBACK_PGK_RES:
dsdl_path = pkg_resources.resource_filename(__name__, "dsdl_specs") # @UndefinedVariable
else:
dsdl_path = importlib_files(__package__).joinpath("dsdl_specs")
# check if we are a package, if not directly use relative DSDL path
if not os.path.exists(dsdl_path):
DSDL_paths = [ "../../DSDL", "../../../../../DroneCAN/DSDL", "../../../../dsdl"]
Expand Down Expand Up @@ -194,7 +205,7 @@ def create_instance(*args, **kwargs):
if str(ext_namespace) != "uavcan":
# noinspection PyUnresolvedReferences
MODULE.thirdparty.__dict__[str(ext_namespace)] = root_namespace.__dict__[ext_namespace]

__all__ = ["dsdl", "transport", "load_dsdl", "DATATYPES", "TYPENAMES"]


Expand Down