Closed erlend-aasland closed 2 months ago
I've added PoC-branches for each proposed solution. Happy to open a PR for whatever variant you prefer.
There's also a third way to mitigate this: conditionally add PdoBase.export
, depending on if canmatrix
is installed or not. This can be trivially added on top of https://github.com/erlend-aasland/canopen/commit/69444dbf0db231dc861410960f4a1803ce783564.
I prefer the third solution. It seems this is the only place where the dependency is used, so forcing all users to install it is too much. But the mapping export function itself is surely useful.
Can we make sure that the canmatrix
package is installed when running tests? Like adding a "test-only dependency" to the pytest config?
Ideally, the function would just raise a more helpful exception in case the import fails.
Yep, the third solution is probably easiest on users. I'll create a PR shortly.
PdoBase.export()
depends on the third-party modulecanmatrix
, which was removed from thecanopen
requirements with commit c46228f9cf2d2661166d68e7175f3e8b99064194, three years ago. This implies it has been de facto broken since that commit, unless the user accidentally had a compatiblecanmatrix
library installed.There's a couple of ways to mitigate this:
canmatrix
dependency, fix.export()
(if it needs fixing), and add unit tests in order to prevent future regressions like thiscanopen
FWIW, my personal preference would be 2).
Discovered while working on increasing PDO coverage to 100%.