1{ stdenv, buildPythonPackage, fetchPypi, libusb1, pytest }:
2
3buildPythonPackage rec {
4 pname = "libusb1";
5 version = "1.7.1";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "adf64a4f3f5c94643a1286f8153bcf4bc787c348b38934aacd7fe17fbeebc571";
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}