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