[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-28 Thread Martin Panter

Martin Panter added the comment:

I am realizing that many people like to use find_library() as a way of 
converting a portable name like “magic” (from building with -lmagic) into a 
platform-specific name (libmagic.so.1, libmagic.dylib, magic.dll, etc), and 
then pass this to LoadLibrary() or equivalent. So searching Python’s runpath 
would probably be valid for that use case.

IMO the extra searching is inefficient, and not robust if there is more than 
one version of the library. Personally I would be more interested in adding an 
alternative function, maybe make_library_name("magic", "1") -> "libmagic.so.1", 
or cdll.LoadLibraryByPortableName("magic", "1").

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-27 Thread Richard PALO

Richard PALO added the comment:

[fingers not yet warmed up] that is '/opt/local/lib/libmagic.so'

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-27 Thread Richard PALO

Richard PALO added the comment:

An example:

richard@omnis:/home/richard$ python2.7
Python 2.7.11 (default, Apr 27 2016, 04:35:25) 
[GCC 4.9.3] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> from ctypes.util import find_library
>>> find_library('magic')
>>> cdll.LoadLibrary('libmagic.so')


Finally, as you can see above, LoadLibrary() works fine to load 
'/opt/local/libmagic.so' because of the runpath in the python binary, but 
find_library() does not because the runpath is ignored.

This should probably be considered as 'unexpected' behaviour.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-27 Thread Richard PALO

Richard PALO added the comment:

oups... I meant to add the comment about $ORIGIN (not really useful here) but 
also the fact that the binary python is built with the dependencies found via 
the library path (-L, for example) and the eventual run-paths (-R or -runpath) 
when not in the system paths.

As indicated by automatthias@, package managers such as pkgsrc, CSW, *ports and 
the like have their $PREFIX off of the system main path..  usually in /usr/pkg, 
/usr/local, /opt/local or something like that
(for unices and linux sort of systems, anyway).

My pkgsrc python2.7 binary has the following runpath:
```
richard@omnis:/home/richard$ dump -Lpv /opt/local/bin/python2.7 |grep RPATH
[12]RPATH   
/opt/pbulk32/gcc49/i486-sun-solaris2.11/lib/.:/opt/pbulk32/gcc49/lib/.:/opt/local/lib
```

What is being requested greatly simplifies things, and can probably be 
generalised to other ELF based systems too.

BTW I came across the issue as well with py-magic.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-26 Thread Richard PALO

Richard PALO added the comment:

There *is* a feature with linking called $ORIGIN.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

find_library() is documented as emulating the build-time linker, and I suspect 
the RPATH of the Python executable is not relevant at build time. See also 
Issue 9998 and Issue 18502.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2015-12-19 Thread Richard PALO

Richard PALO added the comment:

I tried this patch out on pkgsrc, it does seem reasonable and appropriate. So 
+1 from me.

It does only look for libraries the actual $PREFIX directory used by packaging 
systems such as pkgsrc and csw. (typically /usr/local, /opt/local or /opt/csw 
in the case of csw)

So for completeness, perhaps consideration should be made some time for cases 
such as when environment variables like LD_LIBRARY_PATH*, LD_CONFIG* et cetera 
are used... BTW, LD_LIBRARY_PATH is also used on other ELF platforms.

--
nosy: +risto3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-22 Thread Maciej Bliziński

Maciej Bliziński added the comment:

The specific case that breaks for me is this:

OpeCSW Python package includes:

/opt/csw/bin/python2.6 (also 2.7, 3.3, etc)
/opt/csw/lib/libpython2.6.so.1.0
(other files)

On the operating system there is only:
/usr/lib/libpython2.4.so.1.0

Let's say there's libmagic installed in /opt/csw/lib, and there's no libmagic 
in /usr/lib. Let's suppose you run this:

ctypes.cdll.LoadLibrary('libmagic.so.1')

The OpenCSW Python will successfully load libmagic.so.1. But without the patch, 
find_library will not find libmagic.so.1, it will fail to translate 'magic' to 
'libmagic.so.1', even though the libmagic.so symlink is present in /opt/csw/lib.

For the patch, the RPATH of the library itself doesn't matter, the important 
one is the RPATH of the Python executable itself, which influences what 
_ctypes.dlopen() does when looking for a library.

I could write a test by providing providing a sample /usr/ccs/bin/dump output 
and mocking out some libraries. Would that be good?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-21 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


--
versions: +Python 2.6, Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-21 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +jcea

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-21 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

Patch looks good. Any other reviewer?

Maciej, do you know about any generally available library in Solaris with 
SONAME and RPATH?. A test would be nice.

Would this patch solve the locate the C library using ctypes, in Solaris? :-).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-21 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
keywords: +needs review -patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-21 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

/usr/bin/chkpass.so has both SONAME and RPATH.

Would you mind, anyway, to elaborate a bit your use case, including some 
example?. Thanks!.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-21 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

I mean /usr/lib/chkpass.so.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

New submission from Maciej Bliziński:

On Solaris, when you want to link shared libraries from custom directories, you 
most often don't modify the system search path, but instead set RPATH in your 
binaries. For example, OpenCSW packages Python into /opt/csw, and sets Python 
executable's RPATH to /opt/csw/lib. Therefore, dynamically opening shared 
libraries will by default look into /opt/csw/lib first, and find_library should 
do the same. I wrote a sample implementation.

--
components: ctypes
files: find_library_looks_into_rpath.patch
keywords: patch
messages: 200593
nosy: automatthias
priority: normal
severity: normal
status: open
title: ctypes.util.find_library should examine binary's RPATH on Solaris
type: enhancement
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file32255/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


Removed file: 
http://bugs.python.org/file32255/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


Added file: http://bugs.python.org/file32256/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


Removed file: 
http://bugs.python.org/file32256/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


Added file: http://bugs.python.org/file32257/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


Removed file: 
http://bugs.python.org/file32257/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2013-10-20 Thread Maciej Bliziński

Changes by Maciej Bliziński maciej.blizin...@gmail.com:


Added file: http://bugs.python.org/file32259/find_library_looks_into_rpath.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19317
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com