components/python/python26/patches/Python26-14-ctypes-util-find-library.patch
author Norm Jacobs <Norm.Jacobs@Oracle.COM>
Tue, 01 Mar 2011 14:19:15 -0800
changeset 115 c360825c3a3f
parent 99 components/python/python26/Python26-14-ctypes-util-find-library.patch@c15c9099bb44
child 3671 91f76aae1155
permissions -rw-r--r--
7022166 userland patches should move to subdirs

diff --git Python-2.6.4/Lib/ctypes/util.py Python-2.6.4/Lib/ctypes/util.py
--- Python-2.6.4/Lib/ctypes/util.py
+++ Python-2.6.4/Lib/ctypes/util.py
@@ -164,6 +164,35 @@
             res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y)))
             return res[-1]
 
+    elif sys.platform == "sunos5":
+
+        def _findLib_crle(name, is64):
+            if not os.path.exists('/usr/bin/crle'):
+                return None
+
+            if is64:
+                cmd = 'env LC_ALL=C /usr/bin/crle -64 2>/dev/null'
+            else:
+                cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null'
+
+            for line in os.popen(cmd).readlines():
+                line = line.strip()
+                if (line.startswith('Default Library Path (ELF):')):
+                    paths = line.split()[4]
+
+            if not paths:
+                return None
+
+            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, is64 = False):
+            return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
+
     else:
 
         def _findLib_ldconfig(name):