[PATCH evemu 03/11] py: Don't use find_library for libevemu.so
Peter Hutterer
peter.hutterer at who-t.net
Thu Jan 2 16:36:36 PST 2014
On Thu, Jan 02, 2014 at 10:47:53PM +0100, Daniel Martin wrote:
> 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)
fwiw, I'd really prefer this to be ctypes.util.find_library, with the import
statement removed from __init_.py. evemu's python bits are barely maintained
and certainly not by python developers so anything that's more expressive in
patch review will help.
(this goes for the from evemu import foo statements too)
>
> 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
fwiw, I think this file needs further cleaning up, there are quite a few
unused functions.
and having the API in a list in here is quite depressing too.
having said that, Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
for this patch
Cheers,
Peter
> 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
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools
More information about the Input-tools
mailing list