about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/python/cpython/2.7/2.5.2-ctypes-util-find_library.patch
blob: 22bc0f7ced0a7bb1d14abe910c13e0c3dbcfbba7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- origsrc/Lib/ctypes/util.py	2007-09-14 15:05:26.000000000 -0500
+++ src/Lib/ctypes/util.py	2008-11-25 17:54:47.319296200 -0600
@@ -41,6 +41,20 @@
                 continue
         return None
 
+elif sys.platform == "cygwin":
+    def find_library(name):
+        for libdir in ['/usr/lib', '/usr/local/lib']:
+            for libext in ['lib%s.dll.a' % name, 'lib%s.a' % name]:
+                implib = os.path.join(libdir, libext)
+                if not os.path.exists(implib):
+                    continue
+                cmd = "dlltool -I " + implib + " 2>/dev/null"
+                res = os.popen(cmd).read().replace("\n","")
+                if not res:
+                    continue
+                return res
+        return None
+
 elif os.name == "posix":
     # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
     import re, tempfile, errno
@@ -157,6 +173,10 @@
             print cdll.LoadLibrary("libcrypto.dylib")
             print cdll.LoadLibrary("libSystem.dylib")
             print cdll.LoadLibrary("System.framework/System")
+        elif sys.platform == "cygwin":
+            print cdll.LoadLibrary("cygbz2-1.dll") 
+            print find_library("crypt")
+            print cdll.LoadLibrary("cygcrypt-0.dll") 
         else:
             print cdll.LoadLibrary("libm.so")
             print cdll.LoadLibrary("libcrypt.so")