diff -r 1383a260b66d Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst Wed Feb 10 01:17:51 2016 +0000 +++ b/Doc/library/ctypes.rst Sun Feb 21 21:00:51 2016 +0100 @@ -1252,15 +1252,15 @@ On Linux, :func:`find_library` tries to run external programs (``/sbin/ldconfig``, ``gcc``, and ``objdump``) to find the library file. It -returns the filename of the library file. Here are some examples:: +returns the absolute path of the library file. Here are some examples:: >>> from ctypes.util import find_library >>> find_library("m") - 'libm.so.6' + '/lib/x86_64-linux-gnu/libm.so.6' >>> find_library("c") - 'libc.so.6' + '/lib/x86_64-linux-gnu/libc.so.6' >>> find_library("bz2") - 'libbz2.so.1.0' + '/lib/x86_64-linux-gnu/libbz2.so.1.0' >>> On OS X, :func:`find_library` tries several predefined naming schemes and paths @@ -1829,6 +1829,9 @@ The exact functionality is system dependent. + .. versionchanged:: 3.6 + On Linux it returns an absolute path. + .. function:: find_msvcrt() :module: ctypes.util diff -r 1383a260b66d Lib/ctypes/test/test_find.py --- a/Lib/ctypes/test/test_find.py Wed Feb 10 01:17:51 2016 +0000 +++ b/Lib/ctypes/test/test_find.py Sun Feb 21 21:00:51 2016 +0100 @@ -64,6 +64,25 @@ self.skipTest('lib_gle not available') self.gle.gleGetJoinStyle + def test_abspath(self): + lib_gl = lib_glu = lib_gle = None + if sys.platform == "win32": + lib_gl = find_library("OpenGL32") + lib_glu = find_library("Glu32") + elif sys.platform == "darwin": + lib_gl = lib_glu = find_library("OpenGL") + else: + lib_gl = find_library("GL") + lib_glu = find_library("GLU") + lib_gle = find_library("gle") + + if lib_gl: + self.assertTrue(os.path.isabs(lib_gl)) + if lib_glu: + self.assertTrue(os.path.isabs(lib_glu)) + if lib_gle: + self.assertTrue(os.path.isabs(lib_gle)) + # On platforms where the default shared library suffix is '.so', # at least some libraries can be loaded as attributes of the cdll # object, since ctypes now tries loading the lib again diff -r 1383a260b66d Lib/ctypes/util.py --- a/Lib/ctypes/util.py Wed Feb 10 01:17:51 2016 +0000 +++ b/Lib/ctypes/util.py Sun Feb 21 21:00:51 2016 +0100 @@ -222,7 +222,7 @@ # XXX assuming GLIBC's ldconfig (with option -p) regex = os.fsencode( - '\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)) + r'lib%s\.[^\s]+\s\(%s(?:,\s.*)?\)\s=>\s(.*)' % (re.escape(name), abi_type)) try: with subprocess.Popen(['/sbin/ldconfig', '-p'], stdin=subprocess.DEVNULL,