author | John Beck <John.Beck@Oracle.COM> |
Thu, 21 Jul 2016 12:51:35 -0700 | |
changeset 6445 | 0edecb568b2e |
parent 3671 | 91f76aae1155 |
child 7516 | 09c933391a1b |
permissions | -rw-r--r-- |
3671
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
1 |
This patch was developed in-house. It has been submitted upstream: |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
2 |
http://bugs.python.org/issue23287 |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
3 |
|
6445
0edecb568b2e
23858073 Upgrade Python 2.7 line to 2.7.12
John Beck <John.Beck@Oracle.COM>
parents:
3671
diff
changeset
|
4 |
--- Python-2.7.12/Lib/ctypes/util.py.~1~ 2016-06-25 14:49:30.000000000 -0700 |
0edecb568b2e
23858073 Upgrade Python 2.7 line to 2.7.12
John Beck <John.Beck@Oracle.COM>
parents:
3671
diff
changeset
|
5 |
+++ Python-2.7.12/Lib/ctypes/util.py 2016-07-07 14:25:48.212744320 -0700 |
0edecb568b2e
23858073 Upgrade Python 2.7 line to 2.7.12
John Beck <John.Beck@Oracle.COM>
parents:
3671
diff
changeset
|
6 |
@@ -176,23 +176,11 @@ |
3671
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
7 |
|
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
8 |
elif sys.platform == "sunos5": |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
9 |
|
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
10 |
- def _findLib_crle(name, is64): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
11 |
- if not os.path.exists('/usr/bin/crle'): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
12 |
- return None |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
13 |
- |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
14 |
+ def _findLib_path(name, is64): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
15 |
if is64: |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
16 |
- cmd = 'env LC_ALL=C /usr/bin/crle -64 2>/dev/null' |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
17 |
+ paths = "/lib/64:/usr/lib/64" |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
18 |
else: |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
19 |
- cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null' |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
20 |
- |
6445
0edecb568b2e
23858073 Upgrade Python 2.7 line to 2.7.12
John Beck <John.Beck@Oracle.COM>
parents:
3671
diff
changeset
|
21 |
- paths = None |
3671
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
22 |
- for line in os.popen(cmd).readlines(): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
23 |
- line = line.strip() |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
24 |
- if line.startswith('Default Library Path (ELF):'): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
25 |
- paths = line.split()[4] |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
26 |
- |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
27 |
- if not paths: |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
28 |
- return None |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
29 |
+ paths = "/lib:/usr/lib" |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
30 |
|
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
31 |
for dir in paths.split(":"): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
32 |
libfile = os.path.join(dir, "lib%s.so" % name) |
6445
0edecb568b2e
23858073 Upgrade Python 2.7 line to 2.7.12
John Beck <John.Beck@Oracle.COM>
parents:
3671
diff
changeset
|
33 |
@@ -202,7 +190,7 @@ |
3671
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
34 |
return None |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
35 |
|
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
36 |
def find_library(name, is64 = False): |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
37 |
- return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name)) |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
38 |
+ return _get_soname(_findLib_path(name, is64) or _findLib_gcc(name)) |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
39 |
|
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
40 |
else: |
91f76aae1155
20381830 ctypes module unable to obtain default library path
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
41 |