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