Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes how
libudev
is loaded.Using
ctypes.cdll.LoadLibrary
Currently,
ctypes.cdll.LoadLibrary()
is called usinglibudev.so
. According to the docs, the argument must be a filename. In Debian-based distributions (Debian & Ubuntu), the packagelibudev1
contains a filelibudev.so.1
, but notlibudev.so
:This is by design. The trailing
.1
gives the ABI version of the library. Applications should load a library using the ABI version to avoid compatibility issues, because a change of the ABI version means a breaking change that may lead to runtime issues in the application. Thus, no symlink fromlibudev.so
tolibudev.so.1
is created on installation of the package.The package
libudev-dev
containslibudev.so
. As a consequence, loading of thelibudev
library currently only works if either the packagelibudev-dev
is installed or a symlink is created fromlibudev.so
tolibudev.so.1
.Using
ctypes.CDLL
If loading by
LoadLibrary()
fails, a second attempt is made usingctypes.CDLL
. When this also fails, anImportError
should be thrown. This does not work currently becausectypes.CDLL
always returns something that is notNone
.Thus, the
ImportError
is not thrown, and the application fails later when trying to use the library.