Ke Wang-san wrote (02/17/09 05:33 PM):
> This seems to be a bug of python.
> ctypes.util.find_library() does not work correctly.
> I've submitted a patch for libproxy python binding to avoid the use of
> find_library.
>
> You can now try the following python sample code with python2.6:
>
> ////////////////////////////////////////////////////
>
> import libproxy
>
> URL = "http://www.google.com"
>
> pf = libproxy.ProxyFactory()
> for proxy in pf.getProxies(URL):
> print proxy
>
> ////////////////////////////////////////////////////
>
> I also filed a bug to bugs.python.org. The link is:
> http://bugs.python.org/issue5289
OK, thanks for your workaround. I confirmed the example program works.
I read util.py now. My idea is to check LD_LIBRARY_PATH to fix
ctypes.util.find_library() .
--- /usr/lib/python2.6/ctypes/util.py.orig 2009-02-17 18:02:17.764163000
+0900
+++ /usr/lib/python2.6/ctypes/util.py 2009-02-17 19:09:34.251456000 +0900
@@ -159,6 +159,9 @@
else:
def _findLib_ldconfig(name):
+ if not os.path.exists('/sbin/ldconfig'):
+ return None
+
# XXX assuming GLIBC's ldconfig (with option -p)
expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
res = re.search(expr,
@@ -171,8 +174,24 @@
return None
return res.group(0)
+ def _findLib_env(name):
+ paths = os.environ.get('LD_LIBRARY_PATH')
+ if paths:
+ paths += ':/usr/lib'
+ else:
+ paths = '/usr/lib'
+
+ for dir in paths.split(":"):
+ libfile = os.path.join(dir, "lib%s.so" % name)
+ if os.path.exists(libfile):
+ return libfile
+
+ return None
+
def find_library(name):
- return _get_soname(_findLib_ldconfig(name) or _findLib_gcc(name))
+ return _get_soname(_findLib_ldconfig(name) or
+ _findLib_env(name) or
+ _findLib_gcc(name))
################################################################
# test code
>
> Regards,
>
> Ke
>
>
>