From 904ca8ff630cb81fbd35ba337de12643376e058e Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Wed, 17 Jun 2015 13:02:04 +0530 Subject: Raise Exception if ctypes.CDLL() cannot load .so Usually, this failure happens in source installs of glusterfs. find_library() is able to find the .so file but ctypes.CDLL() cannot load it! Refer: http://bugs.python.org/issue18502 With this change, users are advised to modify LD_LIBRARY_PATH when exception is raised Also, passed the LD_LIBRARY_PATH env variable to tox environment so that unit tests and functional tests can run. Change-Id: Iffc5633088b3886739a8534692db88db7c3d02b7 Signed-off-by: Prashanth Pai --- gluster/api.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gluster') diff --git a/gluster/api.py b/gluster/api.py index 1b5d320..6bbd092 100755 --- a/gluster/api.py +++ b/gluster/api.py @@ -32,10 +32,14 @@ if so_file_name is None: # Looks like ctypes is having trouble with dependencies, so just force them to # load with RTLD_GLOBAL until I figure that out. -client = ctypes.CDLL(so_file_name, ctypes.RTLD_GLOBAL, use_errno=True) -# The above statement "may" fail with OSError on some systems if libgfapi.so -# is located in /usr/local/lib/. This happens when glusterfs is installed from -# source. Refer to: http://bugs.python.org/issue18502 +try: + client = ctypes.CDLL(so_file_name, ctypes.RTLD_GLOBAL, use_errno=True) + # The above statement "may" fail with OSError on some systems if + # libgfapi.so is located in /usr/local/lib/. This happens when glusterfs + # is installed from source. Refer to: http://bugs.python.org/issue18502 +except OSError: + raise ImportError("ctypes.CDLL() cannot load {0}. You might want to set " + "LD_LIBRARY_PATH env variable".format(so_file_name)) # Wow, the Linux kernel folks really play nasty games with this structure. If # you look at the man page for stat(2) and then at this definition you'll note -- cgit