[PATCH evemu 03/19] py: Don't use find_library for libevemu.so

Daniel Martin consume.noise at gmail.com
Mon Jan 6 09:38:03 PST 2014


The current mechanism to find libevemu.so prefered a system wide
installed version and if found it ignored the in tree build one.
That's bad for running the tests as they should be performed on the in
tree build library.

So, don't use find_library for libevemu.so and let CDLL do its job. It
even takes LD_LIBRARY_PATH into account, which find_library doesn't.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 python/evemu/__init__.py         | 2 +-
 python/evemu/base.py             | 6 ++----
 python/evemu/const.py            | 2 --
 python/evemu/testing/testcase.py | 7 -------
 python/evemu/tests/test_base.py  | 4 ++--
 5 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py
index 5d7f672..3f8e801 100644
--- a/python/evemu/__init__.py
+++ b/python/evemu/__init__.py
@@ -54,7 +54,7 @@ class Device(object):
             raise TypeError("expected file or file name")
 
         self._is_propfile = self._check_is_propfile(self._file)
-        self._evemu = evemu.base.EvEmuBase(find_library(evemu.const.LIB))
+        self._evemu = evemu.base.EvEmuBase()
         self._uinput = None
 
         libevemu_new = self._evemu.get_lib().evemu_new
diff --git a/python/evemu/base.py b/python/evemu/base.py
index 84e0306..b3e3234 100644
--- a/python/evemu/base.py
+++ b/python/evemu/base.py
@@ -10,10 +10,8 @@ class EvEmuBase(object):
     """
     A base wrapper class for the evemu functions, accessed via ctypes.
     """
-    def __init__(self, library=""):
-        if not library:
-            library = const.LIB
-        self._lib = ctypes.CDLL(library, use_errno=True)
+    def __init__(self):
+        self._lib = ctypes.CDLL(const.LIB, use_errno=True)
         self._libc = ctypes.CDLL(find_library("c"), use_errno=True)
 
     def _call0(self, api_call, *parameters):
diff --git a/python/evemu/const.py b/python/evemu/const.py
index ab2f443..bd1bcde 100644
--- a/python/evemu/const.py
+++ b/python/evemu/const.py
@@ -1,6 +1,4 @@
 LIB = "libevemu.so"
-DEFAULT_LIB = "/usr/lib/libevemu.so"
-LOCAL_LIB = "../src/.libs/libevemu.so"
 UINPUT_NODE = "/dev/uinput"
 MAX_EVENT_NODE = 32
 UINPUT_MAX_NAME_SIZE = 80 # defined in linux/uinput.h
diff --git a/python/evemu/testing/testcase.py b/python/evemu/testing/testcase.py
index 35b7a0b..f19504a 100644
--- a/python/evemu/testing/testcase.py
+++ b/python/evemu/testing/testcase.py
@@ -46,13 +46,6 @@ class BaseTestCase(unittest.TestCase):
 
     def setUp(self):
         super(BaseTestCase, self).setUp()
-        library = find_library(const.LIB)
-        if not library:
-            if os.path.exists(const.DEFAULT_LIB):
-                library = const.DEFAULT_LIB
-            else:
-                library = const.LOCAL_LIB
-        self.library = library
         basedir = get_top_directory()
         self.data_dir = os.path.join(basedir, "..", "..", "data")
         self.device = None
diff --git a/python/evemu/tests/test_base.py b/python/evemu/tests/test_base.py
index 6d7f36e..01dd965 100644
--- a/python/evemu/tests/test_base.py
+++ b/python/evemu/tests/test_base.py
@@ -8,14 +8,14 @@ from evemu.testing import testcase
 class EvEmuBaseTestCase(testcase.BaseTestCase):
 
     def test_so_library_found(self):
-        wrapper = EvEmuBase(self.library)
+        wrapper = EvEmuBase()
         # Make sure that the library loads
         self.assertNotEqual(
             wrapper._lib._name.find("libevemu"), -1)
 
     def test_c_symbols_found(self):
         # Make sure that the expected functions are present
-        wrapper = EvEmuBase(self.library)
+        wrapper = EvEmuBase()
         for function_name in const.API:
             function = getattr(wrapper._lib, function_name)
             self.assertTrue(function is not None)
-- 
1.8.5.2



More information about the Input-tools mailing list