summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Hamb├╝chen <mail@nh2.me>2017-05-13 18:54:36 +0200
committerAmar Tumballi <amarts@redhat.com>2018-03-24 05:10:31 +0000
commit0056feaa21489910fa4ef18668602e1f0967ea6c (patch)
tree3094a6498469efbb4a12ddffe3f5c97b086dfcec
parentaaa4e373f3c7093fa13d0882a034f35aba2761a1 (diff)
python: Remove all uses of find_library. Fixes #1450593
`find_library()` doesn't consider LD_LIBRARY_PATH on Python < 3.6. Change-Id: Iee26085cb5d14061001f19f032c2664d69a378a8 BUG: 1450593 Signed-off-by: Niklas Hamb├╝chen <mail@nh2.me>
-rwxr-xr-xapi/examples/getvolfile.py2
-rw-r--r--geo-replication/syncdaemon/libcxattr.py3
-rw-r--r--geo-replication/syncdaemon/libgfchangelog.py3
-rwxr-xr-xtests/features/ipctest.py10
-rw-r--r--tests/utils/libcxattr.py5
-rw-r--r--tools/glusterfind/src/libgfchangelog.py3
-rw-r--r--xlators/features/changelog/lib/examples/python/libgfchangelog.py3
7 files changed, 9 insertions, 20 deletions
diff --git a/api/examples/getvolfile.py b/api/examples/getvolfile.py
index 0c95213f0b6..32c2268b313 100755
--- a/api/examples/getvolfile.py
+++ b/api/examples/getvolfile.py
@@ -3,7 +3,7 @@
import ctypes
import ctypes.util
-api = ctypes.CDLL(ctypes.util.find_library("gfapi"))
+api = ctypes.CDLL("libgfapi.so")
api.glfs_get_volfile.argtypes = [ctypes.c_void_p,
ctypes.c_void_p,
ctypes.c_ulong]
diff --git a/geo-replication/syncdaemon/libcxattr.py b/geo-replication/syncdaemon/libcxattr.py
index 3671e102c7f..f576648b7a8 100644
--- a/geo-replication/syncdaemon/libcxattr.py
+++ b/geo-replication/syncdaemon/libcxattr.py
@@ -10,7 +10,6 @@
import os
from ctypes import CDLL, create_string_buffer, get_errno
-from ctypes.util import find_library
class Xattr(object):
@@ -25,7 +24,7 @@ class Xattr(object):
sizes we expect
"""
- libc = CDLL(find_library("c"), use_errno=True)
+ libc = CDLL("libc.so.6", use_errno=True)
@classmethod
def geterrno(cls):
diff --git a/geo-replication/syncdaemon/libgfchangelog.py b/geo-replication/syncdaemon/libgfchangelog.py
index 334f5e9eaf2..da12438d069 100644
--- a/geo-replication/syncdaemon/libgfchangelog.py
+++ b/geo-replication/syncdaemon/libgfchangelog.py
@@ -11,12 +11,11 @@
import os
from ctypes import CDLL, RTLD_GLOBAL, create_string_buffer, \
get_errno, byref, c_ulong
-from ctypes.util import find_library
from syncdutils import ChangelogException, ChangelogHistoryNotAvailable
class Changes(object):
- libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL,
+ libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL,
use_errno=True)
@classmethod
diff --git a/tests/features/ipctest.py b/tests/features/ipctest.py
index 5aff319b8d0..93392486140 100755
--- a/tests/features/ipctest.py
+++ b/tests/features/ipctest.py
@@ -1,14 +1,8 @@
#!/usr/bin/python
import ctypes
-import ctypes.util
-
-# find_library does not lookup LD_LIBRARY_PATH and may miss the
-# function. In that case, retry with less portable but explicit name.
-libgfapi = ctypes.util.find_library("gfapi")
-if libgfapi == None:
- libgfapi = "libgfapi.so"
-api = ctypes.CDLL(libgfapi,mode=ctypes.RTLD_GLOBAL)
+
+api = ctypes.CDLL("libgfapi.so",mode=ctypes.RTLD_GLOBAL)
api.glfs_ipc.argtypes = [ ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p ]
api.glfs_ipc.restype = ctypes.c_int
diff --git a/tests/utils/libcxattr.py b/tests/utils/libcxattr.py
index 149db72e6ee..4e6e6c46df9 100644
--- a/tests/utils/libcxattr.py
+++ b/tests/utils/libcxattr.py
@@ -11,7 +11,6 @@
import os
import sys
from ctypes import CDLL, c_int, create_string_buffer
-from ctypes.util import find_library
class Xattr(object):
@@ -28,9 +27,9 @@ class Xattr(object):
if sys.hexversion >= 0x02060000:
from ctypes import DEFAULT_MODE
- libc = CDLL(find_library("libc"), DEFAULT_MODE, None, True)
+ libc = CDLL("libc.so.6", DEFAULT_MODE, None, True)
else:
- libc = CDLL(find_library("libc"))
+ libc = CDLL("libc.so.6")
@classmethod
def geterrno(cls):
diff --git a/tools/glusterfind/src/libgfchangelog.py b/tools/glusterfind/src/libgfchangelog.py
index b7d8efcb4e4..afb3387db2d 100644
--- a/tools/glusterfind/src/libgfchangelog.py
+++ b/tools/glusterfind/src/libgfchangelog.py
@@ -11,14 +11,13 @@
import os
from ctypes import CDLL, get_errno, create_string_buffer, c_ulong, byref
from ctypes import RTLD_GLOBAL
-from ctypes.util import find_library
class ChangelogException(OSError):
pass
-libgfc = CDLL(find_library("gfchangelog"), use_errno=True, mode=RTLD_GLOBAL)
+libgfc = CDLL("libgfchangelog.so", use_errno=True, mode=RTLD_GLOBAL)
def raise_oserr(prefix=None):
diff --git a/xlators/features/changelog/lib/examples/python/libgfchangelog.py b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
index 10e73c02b34..2cdbf1152b9 100644
--- a/xlators/features/changelog/lib/examples/python/libgfchangelog.py
+++ b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
@@ -1,9 +1,8 @@
import os
from ctypes import *
-from ctypes.util import find_library
class Changes(object):
- libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True)
+ libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL, use_errno=True)
@classmethod
def geterrno(cls):