This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3.4-ctypes-cygwin.patch
51 lines (49 loc) · 2.1 KB
/
3.4-ctypes-cygwin.patch
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- origsrc/Python-3.4.3/Lib/ctypes/__init__.py 2015-02-25 05:27:44.000000000 -0600
+++ src/Python-3.4.3/Lib/ctypes/__init__.py 2015-05-05 11:39:39.945940300 -0500
@@ -434,7 +434,8 @@ pydll = LibraryLoader(PyDLL)
if _os.name in ("nt", "ce"):
pythonapi = PyDLL("python dll", None, _sys.dllhandle)
elif _sys.platform == "cygwin":
- pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
+ pythonapi = PyDLL("libpython%d.%d%s.dll" % \
+ (_sys.version_info[:2] + tuple(_sys.abiflags)))
else:
pythonapi = PyDLL(None)
--- origsrc/Python-3.4.3/Lib/ctypes/util.py 2015-02-25 05:27:44.000000000 -0600
+++ src/Python-3.4.3/Lib/ctypes/util.py 2015-05-05 11:10:45.202655900 -0500
@@ -83,6 +83,25 @@ if os.name == "posix" and sys.platform =
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"
+ f = os.popen(cmd)
+ try:
+ data = f.read()
+ finally:
+ f.close()
+ res = data.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
@@ -258,6 +277,10 @@ def test():
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(cdll.LoadLibrary("cygcrypt-0.dll"))
+ print(find_library("crypt"))
else:
print(cdll.LoadLibrary("libm.so"))
print(cdll.LoadLibrary("libcrypt.so"))