1{ stdenv, lib, buildPythonPackage, fetchPypi, python, libusb1 }:
2
3buildPythonPackage rec {
4 pname = "libusb1";
5 version = "1.6.6";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "a49917a2262cf7134396f6720c8be011f14aabfc5cdc53f880cc672c0f39d271";
10 };
11
12 postPatch = lib.optionalString stdenv.isLinux ''
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 checkPhase = ''
21 ${python.interpreter} -m usb1.testUSB1
22 '';
23
24 meta = with stdenv.lib; {
25 homepage = https://github.com/vpelletier/python-libusb1;
26 description = "Python ctype-based wrapper around libusb1";
27 license = licenses.lgpl2Plus;
28 maintainers = with maintainers; [ rnhmjoj ];
29 };
30}