On 28/09/13 18:04, Paul Colomiets wrote:
> Hi Juan,
>
> On Sat, Sep 28, 2013 at 1:56 PM, "Juan J. Mart�nez" <
j...@usebox.net> wrote:
>> And I monkeypatch ctypes.util.find_library, so pyglet will load my local
>> AVbin version instead of the one on the system (if any!).
>>
>
> I had this problem too on OS X too. But I ended up with setting
> os.environ['DYLD_LIBRARY_PATH'] and renaming libavbin.10.dylib to
> libavbin.dylib. I think you could set "LD_LIBRARY_PATH" on linux too.
IMHO pyglet does the right thing that is to rely on ctypes.utils, and
that one uses system tools such as ldconfig, gcc, objdump, etc.
I didn't like fiddling with LD_* because some Linux distributions may
not allow using them for security reasons (ie. Fedora with selinux
enabled), restricting what ldconfig will do.
BUT since we're not going to use the dynamic linker but ctypes'
LoadLibrary, I though monkeypatching was the cleaner solution to avoid
using the system library even if it exists and at the same time avoid
any security restriction.
(not 100% sure this was needed though)
> I believe that it should be fixed in pyglet rather that relying
> changing environment or monkey patching.
>
> Thoughts?
I'm not sure that there's anything "to fix". The libraries *should* be
installed on the system, but AVbin is not very well supported by Linux
distributions (Ubuntu Precise packages AVbin 7!).
I don't think there's a solution that covers all the cases (in my
example I was supporting both 32 and 64 bits, good luck doing that with
ldconfig hehe). This is perhaps "too advanced" for a general use case.
If I had to support this, I would use a pyglet.options entry with a
callable:
find_local_library
By default None. It is expected to be a callable with one parameter
`name` that will contain the name of the library to load. This callable
must return the path to the platform specific library or None if there's
no local library and ctypes.util.find_library must be used (default
behaviour).
Example:
def find_local_library(name):
import sys
if sys.platform.startswith('linux') and name == "avbin":
return "./lib/libavbin.so"
return None
pyglet.options['find_local_library'] = find_local_library
What do you think? May be you can propose something better :)
Regards,
Juan