1{ stdenv, buildPythonPackage, fetchPypi, libusb1, pytest }:
2
3buildPythonPackage rec {
4 pname = "libusb1";
5 version = "1.8";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "240f65ac70ba3fab77749ec84a412e4e89624804cb80d6c9d394eef5af8878d6";
10 };
11
12 postPatch = ''
13 substituteInPlace usb1/libusb1.py --replace \
14 "ctypes.util.find_library(base_name)" \
15 "'${libusb1}/lib/libusb-1.0${stdenv.hostPlatform.extensions.sharedLibrary}'"
16 '';
17
18 buildInputs = [ libusb1 ];
19
20 checkInputs = [ pytest ];
21
22 checkPhase = ''
23 # USBPollerThread is unreliable. Let's not test it.
24 # See: https://github.com/vpelletier/python-libusb1/issues/16
25 py.test -k 'not testUSBPollerThreadExit' usb1/testUSB1.py
26 '';
27
28 meta = with stdenv.lib; {
29 homepage = "https://github.com/vpelletier/python-libusb1";
30 description = "Python ctype-based wrapper around libusb1";
31 license = licenses.lgpl2Plus;
32 maintainers = with maintainers; [ rnhmjoj ];
33 };
34}