Message273392
On 22-Aug-16 04:04, Martin Panter wrote:
> Martin Panter added the comment:
>
> The ctypes tests all seem to be protected with code that checks for None, and explicitly skip the test in that case. The skip message should be visible when you run the test in verbose mode.
So at least test/test_something.py run cleanly - but why accept code
that always returns None - for find_library().
Rather than "hard-code" proper strings in a test - shouldn't the test be
demonstrating the "failure" of find_library() to return a suitable
response - when it should not be None.
For example, on AIX the IBM provided /usr/lib/libm.a only has static
members. So, what has always been wrong (and noone noticed, or is it
noone cared) the "built-in" test in util.py has, and does, always fail:
root@x064:[/data/prj/aixtools/python/python-2.7.12.0/Lib/ctypes]../../python
util.py
None
None
None
Traceback (most recent call last):
File "util.py", line 271, in <module>
test()
File "util.py", line 266, in test
print cdll.LoadLibrary("libm.so")
File
"/data/prj/aixtools/python/python-2.7.12.0/Lib/ctypes/__init__.py", line
440, in LoadLibrary
return self._dlltype(name)
File
"/data/prj/aixtools/python/python-2.7.12.0/Lib/ctypes/__init__.py", line
362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: 0509-022 Cannot load module .
0509-026 System error: A file or directory in the path name
does not exist.
The documentation says:
The exact functionality is system dependent.
On Linux, |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.
...
On OS X, |find_library()| tries several predefined naming schemes and
paths to locate the library, and returns a full pathname if successful:
...
On Windows, |find_library()| searches along the system search path, and
returns the full pathname, but since there is no predefined naming
scheme a call like |find_library("c")| will fail and return |None|.
Are you saying the documentation should be updated to read:
On AIX, find_library tries to use the Linux code which generally fails
and will return None.
And the closing bit:
If wrapping a shared library with |ctypes|
<https://docs.python.org/2/library/ctypes.html#module-ctypes>, it /may/
be better to determine the shared library name at development time, and
hardcode that into the wrapper module instead of using |find_library()|
to locate the library at runtime (so forget about developing code for
multiple platforms - find_library() cannot give you that support.
p.s. On AIX, you must use a hard-coded name to ctypes.CDLL() - and also
add an extra flag - because even though we said "the exact functionality
is system dependent" we do not permit new systems to add corrections.
I apologize that my frustration is more than peeking through. But I am
frustrated. find_library(), unless I completely misunderstand the
documentation, is a helper function to releave the programmer of needing
to know the specifics of multiple platforms. My frustration is
heightened by what I read about the issues with "uuid" - which also
calls find_library() - so again, on AIX it always returns None -- a)
find_library is broken; b) there is no libuuid.so or libuuid.a on AIX
(and c) 4 of the 5 programs also called do not exist on AIX, and the one
that does generates a different string than is compared to).
I understand - AIX has not been a major (user) platform for python. I am
amazed that noone from IBM (AIX) development has never shown more interest.
Disclaimer: yes, I work for IBM - but am not a developer. Customers do
ask me about "why is python so old, why does it not work with XXX" - and
only because I am inclined to "get to the bottom" did I even start on this.
If the root cause is: "IBM showed no interest X years ago and we,
python, have no interest now in IBM or AIX" then please just say so -
and I shall do other things with my time.
In closing - I thought python was multi-platform and I had hoped to be
of some help in improving python integration with the platform AIX.
Please, one way or the other, help me lessen my frustration.
Thank you for your time and patience with my rant!
> We could avoid skipping these tests in 2.7 by adding a special case for AIX that loads the library via CDLL("libc.a(shr[_64].o)", RTLD_MEMBER). Like an extension of the special cases already at <https://hg.python.org/cpython/file/v2.7.12/Lib/ctypes/test/test_loading.py#l8>, but we have to set the RTLD_ flag as well as the library name.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue27435>
> _______________________________________ |
|
Date |
User |
Action |
Args |
2016-08-22 18:18:31 | aixtools@gmail.com | set | recipients:
+ aixtools@gmail.com, martin.panter, Michael.Felt |
2016-08-22 18:18:31 | aixtools@gmail.com | link | issue27435 messages |
2016-08-22 18:18:31 | aixtools@gmail.com | create | |
|