Author: neusepoff
Origin: http://code.google.com/p/pyglet/issues/detail?id=456#c8
Bug: http://code.google.com/p/pyglet/issues/detail?id=456
Bug-Debian: http://bugs.debian.org/584548
Subject: use find_library first prior adding libraries by a pattern of the name

From original patch comments:

okay, this has to do with the nvidia package of debian providing the
wrong link for the libGL.so alternative (linking to the diversion
instead of the right file), see:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597452

it doesn't harm most software as these are linked agains libGL.so.1
anyway.  but pyglet is trying to load libGL.so first and then falling
back to find_library().

I've attached a patch witch solves this by trying to load the library
using find_library() first and then falling back to the hardcoded
name.

--- a/pyglet/lib.py
+++ b/pyglet/lib.py
@@ -96,7 +96,9 @@ class LibraryLoader(object):
             platform_names = list(platform_names)
 
         if self.platform == 'linux2':
-            platform_names.extend(['lib%s.so' % n for n in names])
+            for name in names:
+                libname = ctypes.util.find_library(name)
+                platform_names.append(libname or 'lib%s.so' % name)
 
         platform_names.extend(names)
         for name in platform_names:
