walac/pyusb — pull request #29 by dywisor (2013-10-21 12:46:54+00:00)
Title: improve backend library locating/loading

This commit adds the ``find_library`` arg to the ``get_backend()`` functions, which allows to override the default library lookup. This is useful on systems where ``ctypes.util.find_library()`` cannot be used, e.g. on embedded linux where gcc and objdump are missing and the library cache is disabled (uclibc without LDSO_CACHE_SUPPORT) [0].

A (super-lazy) usage example for such systems would be
```python
import usb.core
import usb.backend.libusb1

backend = usb.backend.libusb1.get_backend(find_library=lambda x: "/usr/lib/libusb-1.0.so")
dev = usb.core.find(..., backend=backend)
```
Not passing ``find_library`` to ``get_backend()`` keeps the old behavior (but logging is slightly changed).

Other changes:
* libusb0, libusb1, openusb backends use the same code
for lib loading now (usb.libloader)
* specific exceptions (derived from usb.libloader.LibraryException)
are raised if a lib cannot be found or lib loading fails

[0] http://docs.python.org/3/library/ctypes.html#finding-shared-libraries