Skip to content

Commit 090f380

Browse files
Fix entry points for 3rd party interfaces (hardbyte#389)
Fixes backwards incompatible change introduced in 2.2.0. Updated documentation to new entry point.
1 parent 7b3bb42 commit 090f380

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎can/interfaces/__init__.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
Interfaces contain low level implementations that interact with CAN hardware.
66
"""
77

8+
import logging
9+
810
from pkg_resources import iter_entry_points
911

12+
logger = logging.getLogger(__name__)
13+
1014
# interface_name => (module, classname)
1115
BACKENDS = {
1216
'kvaser': ('can.interfaces.kvaser', 'KvaserBus'),
@@ -28,4 +32,10 @@
2832
for interface in iter_entry_points('can.interface')
2933
})
3034

35+
# Old entry point name. May be removed in 3.0.
36+
for interface in iter_entry_points('python_can.interface'):
37+
BACKENDS[interface.name] = (interface.module_name, interface.attrs[0])
38+
logger.warning('%s is using the deprecated python_can.interface entry point. '
39+
'Please change to can.interface instead.', interface.name)
40+
3141
VALID_INTERFACES = frozenset(list(BACKENDS.keys()) + ['socketcan_native', 'socketcan_ctypes'])

‎doc/interfaces.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ The available interfaces are:
2525
interfaces/virtual
2626

2727
Additional interfaces can be added via a plugin interface. An external package
28-
can register a new interface by using the ``python_can.interface`` entry point.
28+
can register a new interface by using the ``can.interface`` entry point in its setup.py.
2929

3030
The format of the entry point is ``interface_name=module:classname`` where
31-
``classname`` is a :class:`can.BusABC` concrete implementation.
31+
``classname`` is a concrete :class:`can.BusABC` implementation.
3232

3333
::
3434

3535
entry_points={
36-
'python_can.interface': [
36+
'can.interface': [
3737
"interface_name=module:classname",
3838
]
3939
},

0 commit comments

Comments
 (0)