1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 setuptools-scm,
7 libusb-package,
8 numpy,
9 packaging,
10 pyserial,
11 pyusb,
12 scipy,
13 pytestCheckHook,
14 pyyaml,
15 udevCheckHook,
16}:
17
18buildPythonPackage rec {
19 pname = "cflib";
20 version = "0.1.28";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "bitcraze";
25 repo = "crazyflie-lib-python";
26 tag = version;
27 hash = "sha256-vGqwQVD80NcFJosVAmqj66uxYNoVtAqzVhVQiuWP5yM=";
28 };
29
30 strictDeps = true;
31
32 build-system = [
33 setuptools
34 setuptools-scm
35 ];
36
37 pythonRelaxDeps = [
38 "numpy"
39 "packaging"
40 ];
41
42 dependencies = [
43 libusb-package
44 numpy
45 packaging
46 pyserial
47 pyusb
48 scipy
49 ];
50
51 disabledTestPaths = [
52 # exception: Cannot find a Crazyradio Dongle (HW required)
53 "sys_test/single_cf_grounded/"
54 "sys_test/swarm_test_rig/"
55 ];
56
57 pythonImportsCheck = [ "cflib" ];
58 nativeCheckInputs = [
59 pytestCheckHook
60 pyyaml
61 ];
62
63 # The udevCheckHook is used to verify udev rules
64 # requires diInstallCheck to be enabled, which is default for pythonPackages
65 nativeInstallCheckInputs = [
66 udevCheckHook
67 ];
68
69 # Install udev rules as defined
70 # https://www.bitcraze.io/documentation/repository/crazyflie-lib-python/master/installation/usb_permissions/
71 postInstall = ''
72 # Install udev rules
73 mkdir -p $out/etc/udev/rules.d
74
75 cat <<EOF > $out/etc/udev/rules.d/99-bitcraze.rules
76 # Crazyradio (normal operation)
77 SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"
78 # Bootloader
79 SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="0101", MODE="0664", GROUP="plugdev"
80 # Crazyflie (over USB)
81 SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"
82 EOF
83 '';
84
85 meta = {
86 description = "Python library for the Crazyflie quadcopter by Bitcraze";
87 homepage = "https://github.com/bitcraze/crazyflie-lib-python";
88 changelog = "https://github.com/bitcraze/crazyflie-lib-python/releases/tag/${version}";
89 license = lib.licenses.gpl2Only;
90 maintainers = [ lib.maintainers.brianmcgillion ];
91 platforms = lib.platforms.linux;
92 };
93}