Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfe3474

Browse files
committed
fix find_library on Solaris (closes #5289)
1 parent 7a34f02 commit cfe3474

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lib/ctypes/util.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,35 @@ def find_library(name):
166166
res.sort(key=_num_version)
167167
return res[-1]
168168

169+
elif sys.platform == "sunos5":
170+
171+
def _findLib_crle(name, is64):
172+
if not os.path.exists('/usr/bin/crle'):
173+
return None
174+
175+
if is64:
176+
cmd = 'env LC_ALL=C /usr/bin/crle -64 2>/dev/null'
177+
else:
178+
cmd = 'env LC_ALL=C /usr/bin/crle 2>/dev/null'
179+
180+
for line in os.popen(cmd).readlines():
181+
line = line.strip()
182+
if line.startswith('Default Library Path (ELF):'):
183+
paths = line.split()[4]
184+
185+
if not paths:
186+
return None
187+
188+
for dir in paths.split(":"):
189+
libfile = os.path.join(dir, "lib%s.so" % name)
190+
if os.path.exists(libfile):
191+
return libfile
192+
193+
return None
194+
195+
def find_library(name, is64 = False):
196+
return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
197+
169198
else:
170199

171200
def _findSoname_ldconfig(name):

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ Richard Walker
12501250
Larry Wall
12511251
Kevin Walzer
12521252
Rodrigo Steinmuller Wanderley
1253+
Ke Wang
12531254
Greg Ward
12541255
Zachary Ware
12551256
Barry Warsaw

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ Core and Builtins
163163
Library
164164
-------
165165

166+
- Issue #5289: Fix ctypes.util.find_library on Solaris.
167+
166168
- Issue #17106: Fix a segmentation fault in io.TextIOWrapper when an underlying
167169
stream or a decoder produces data of an unexpected type (i.e. when
168170
io.TextIOWrapper initialized with text stream or use bytes-to-bytes codec).

0 commit comments

Comments
 (0)