1{
2 lib,
3 stdenv,
4 fetchPypi,
5 buildPythonPackage,
6 libusb1,
7 setuptools-scm,
8}:
9
10buildPythonPackage rec {
11 pname = "pyusb";
12 version = "1.3.1";
13 format = "setuptools";
14
15 src = fetchPypi {
16 inherit pname version;
17 sha256 = "sha256-OvBwtgdGfBwWT0nVsMqr6Kx42+2SmNcDqNv530BS0X4=";
18 };
19
20 nativeBuildInputs = [ setuptools-scm ];
21
22 # Fix the USB backend library lookup
23 postPatch = ''
24 libusb=${libusb1.out}/lib/libusb-1.0${stdenv.hostPlatform.extensions.sharedLibrary}
25 test -f $libusb || { echo "ERROR: $libusb doesn't exist, please update/fix this build expression."; exit 1; }
26 sed -i -e "s|find_library=None|find_library=lambda _:\"$libusb\"|" usb/backend/libusb1.py
27 '';
28
29 # No tests included
30 doCheck = false;
31
32 pythonImportsCheck = [ "usb" ];
33
34 meta = with lib; {
35 description = "Python USB access module (wraps libusb 1.0)"; # can use other backends
36 homepage = "https://pyusb.github.io/pyusb/";
37 license = licenses.bsd3;
38 maintainers = with maintainers; [ bjornfor ];
39 };
40}