1{ lib, stdenv, buildPythonPackage, fetchPypi, libusb1, pytest }:
2
3buildPythonPackage rec {
4 pname = "libusb1";
5 version = "1.9.2";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "17hqck808m59jv6m2g4hasnay44pycy3y0im01fq9jpr3ymcdbi7";
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 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; [ prusnak rnhmjoj ];
33 };
34}