Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b9f3114d
Commit
b9f3114d
authored
Mar 10, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #21042: Return full path in ctypes.util.find_library() on Linux
Patch by Tamás Bence Gedai.
parent
aadaa361
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
22 deletions
+37
-22
Doc/library/ctypes.rst
Doc/library/ctypes.rst
+7
-4
Lib/ctypes/test/test_find.py
Lib/ctypes/test/test_find.py
+24
-16
Lib/ctypes/util.py
Lib/ctypes/util.py
+2
-2
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/ctypes.rst
View file @
b9f3114d
...
...
@@ -1252,15 +1252,15 @@ The exact functionality is system dependent.
On Linux, :func:`find_library` tries to run external programs
(``/sbin/ldconfig``, ``gcc``, and ``objdump``) to find the library file. It
returns the
filename
of the library file. Here are some examples::
returns the
absolute path
of the library file. Here are some examples::
>>> from ctypes.util import find_library
>>> find_library("m")
'libm.so.6'
'
/lib/x86_64-linux-gnu/
libm.so.6'
>>> find_library("c")
'libc.so.6'
'
/lib/x86_64-linux-gnu/
libc.so.6'
>>> find_library("bz2")
'libbz2.so.1.0'
'
/lib/x86_64-linux-gnu/
libbz2.so.1.0'
>>>
On OS X, :func:`find_library` tries several predefined naming schemes and paths
...
...
@@ -1829,6 +1829,9 @@ Utility functions
The exact functionality is system dependent.
.. versionchanged:: 3.6
On Linux it returns an absolute path.
.. function:: find_msvcrt()
:module: ctypes.util
...
...
Lib/ctypes/test/test_find.py
View file @
b9f3114d
...
...
@@ -9,39 +9,39 @@ from ctypes.util import find_library
class
Test_OpenGL_libs
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
lib_gl
=
lib_glu
=
lib_gle
=
None
cls
.
lib_gl
=
cls
.
lib_glu
=
cls
.
lib_gle
=
None
if
sys
.
platform
==
"win32"
:
lib_gl
=
find_library
(
"OpenGL32"
)
lib_glu
=
find_library
(
"Glu32"
)
cls
.
lib_gl
=
find_library
(
"OpenGL32"
)
cls
.
lib_glu
=
find_library
(
"Glu32"
)
elif
sys
.
platform
==
"darwin"
:
lib_gl
=
lib_glu
=
find_library
(
"OpenGL"
)
cls
.
lib_gl
=
cls
.
lib_glu
=
find_library
(
"OpenGL"
)
else
:
lib_gl
=
find_library
(
"GL"
)
lib_glu
=
find_library
(
"GLU"
)
lib_gle
=
find_library
(
"gle"
)
cls
.
lib_gl
=
find_library
(
"GL"
)
cls
.
lib_glu
=
find_library
(
"GLU"
)
cls
.
lib_gle
=
find_library
(
"gle"
)
## print, for debugging
if
test
.
support
.
verbose
:
print
(
"OpenGL libraries:"
)
for
item
in
((
"GL"
,
lib_gl
),
(
"GLU"
,
lib_glu
),
(
"gle"
,
lib_gle
)):
for
item
in
((
"GL"
,
cls
.
lib_gl
),
(
"GLU"
,
cls
.
lib_glu
),
(
"gle"
,
cls
.
lib_gle
)):
print
(
"
\
t
"
,
item
)
cls
.
gl
=
cls
.
glu
=
cls
.
gle
=
None
if
lib_gl
:
if
cls
.
lib_gl
:
try
:
cls
.
gl
=
CDLL
(
lib_gl
,
mode
=
RTLD_GLOBAL
)
cls
.
gl
=
CDLL
(
cls
.
lib_gl
,
mode
=
RTLD_GLOBAL
)
except
OSError
:
pass
if
lib_glu
:
if
cls
.
lib_glu
:
try
:
cls
.
glu
=
CDLL
(
lib_glu
,
RTLD_GLOBAL
)
cls
.
glu
=
CDLL
(
cls
.
lib_glu
,
RTLD_GLOBAL
)
except
OSError
:
pass
if
lib_gle
:
if
cls
.
lib_gle
:
try
:
cls
.
gle
=
CDLL
(
lib_gle
)
cls
.
gle
=
CDLL
(
cls
.
lib_gle
)
except
OSError
:
pass
...
...
@@ -64,6 +64,14 @@ class Test_OpenGL_libs(unittest.TestCase):
self
.
skipTest
(
'lib_gle not available'
)
self
.
gle
.
gleGetJoinStyle
def
test_abspath
(
self
):
if
self
.
lib_gl
:
self
.
assertTrue
(
os
.
path
.
isabs
(
self
.
lib_gl
))
if
self
.
lib_glu
:
self
.
assertTrue
(
os
.
path
.
isabs
(
self
.
lib_glu
))
if
self
.
lib_gle
:
self
.
assertTrue
(
os
.
path
.
isabs
(
self
.
lib_gle
))
# On platforms where the default shared library suffix is '.so',
# at least some libraries can be loaded as attributes of the cdll
# object, since ctypes now tries loading the lib again
...
...
Lib/ctypes/util.py
View file @
b9f3114d
...
...
@@ -221,8 +221,8 @@ elif os.name == "posix":
abi_type = mach_map.get(machine, '
libc6
')
# XXX assuming GLIBC'
s
ldconfig
(
with
option
-
p
)
regex
=
os
.
fsencode
(
'
\
s+(li
b
%s
\
.[^
\
s]+)
\
s+
\
(%s'
%
(
re
.
escape
(
name
),
abi_type
))
regex
=
r'lib%s\
.[^
\s]+\
s
\(%s(?:,\
s.*)?
\)\
s=>
\s(.*)'
regex
=
os
.
fsencode
(
regex
%
(
re
.
escape
(
name
),
abi_type
))
try
:
with
subprocess
.
Popen
([
'/sbin/ldconfig'
,
'-p'
],
stdin
=
subprocess
.
DEVNULL
,
...
...
Misc/ACKS
View file @
b9f3114d
...
...
@@ -487,6 +487,7 @@ Matthieu Gautier
Stephen M. Gava
Xavier de Gaye
Harry Henry Gebel
Tamás Bence Gedai
Marius Gedminas
Jan-Philip Gehrcke
Thomas Gellekum
...
...
Misc/NEWS
View file @
b9f3114d
...
...
@@ -201,6 +201,9 @@ Core and Builtins
Library
-------
-
Issue
#
21042
:
Make
ctypes
.
util
.
find_library
()
return
the
full
path
on
Linux
,
similar
to
other
platforms
.
Patch
by
Tam
á
s
Bence
Gedai
.
-
Issue
#
15068
:
Got
rid
of
excessive
buffering
in
fileinput
.
The
bufsize
parameter
is
now
deprecated
and
ignored
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment