0001-Workaround-finding-libudev-on-systems-without-ldconf.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From e86a1c199d45c9751da67f947af202927dee07f8 Mon Sep 17 00:00:00 2001
  2. From: Yegor Yefremov <yegorslists@googlemail.com>
  3. Date: Thu, 10 Dec 2015 08:44:55 +0100
  4. Subject: [PATCH] Workaround finding libudev on systems without ldconf
  5. This patch tries to load libudev.so directly without relying on
  6. Python's find_library(). find_library() fails on systems
  7. without library cache mechanism.
  8. Taken from pyudev issue 117 discussion:
  9. https://github.com/pyudev/pyudev/pull/117
  10. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
  11. [Marcin: adjust to 0.22.0]
  12. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
  13. ---
  14. src/pyudev/_ctypeslib/utils.py | 8 ++++----
  15. 1 file changed, 4 insertions(+), 4 deletions(-)
  16. diff --git a/src/pyudev/_ctypeslib/utils.py b/src/pyudev/_ctypeslib/utils.py
  17. index 9dffb3c..aa9942f 100644
  18. --- a/src/pyudev/_ctypeslib/utils.py
  19. +++ b/src/pyudev/_ctypeslib/utils.py
  20. @@ -28,7 +28,7 @@
  21. from __future__ import print_function
  22. from __future__ import unicode_literals
  23. -from ctypes import CDLL
  24. +from ctypes import cdll, CDLL
  25. from ctypes.util import find_library
  26. @@ -50,10 +50,10 @@ def load_ctypes_library(name, signatures, error_checkers):
  27. :rtype: ctypes.CDLL
  28. :raises ImportError: if the library is not found
  29. """
  30. - library_name = find_library(name)
  31. - if not library_name:
  32. + try:
  33. + lib = cdll.LoadLibrary(f'lib{name}.so')
  34. + except OSError:
  35. raise ImportError('No library named %s' % name)
  36. - lib = CDLL(library_name, use_errno=True)
  37. # Add function signatures
  38. for funcname, signature in signatures.items():
  39. function = getattr(lib, funcname, None)
  40. --
  41. 2.29.1