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 = [ "numpy" ];
38
39 dependencies = [
40 libusb-package
41 numpy
42 packaging
43 pyserial
44 pyusb
45 scipy
46 ];
47
48 disabledTestPaths = [
49 # exception: Cannot find a Crazyradio Dongle (HW required)
50 "sys_test/single_cf_grounded/"
51 "sys_test/swarm_test_rig/"
52 ];
53
54 pythonImportsCheck = [ "cflib" ];
55 nativeCheckInputs = [
56 pytestCheckHook
57 pyyaml
58 ];
59
60 # The udevCheckHook is used to verify udev rules
61 # requires diInstallCheck to be enabled, which is default for pythonPackages
62 nativeInstallCheckInputs = [
63 udevCheckHook
64 ];
65
66 # Install udev rules as defined
67 # https://www.bitcraze.io/documentation/repository/crazyflie-lib-python/master/installation/usb_permissions/
68 postInstall = ''
69 # Install udev rules
70 mkdir -p $out/etc/udev/rules.d
71
72 cat <<EOF > $out/etc/udev/rules.d/99-bitcraze.rules
73 # Crazyradio (normal operation)
74 SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"
75 # Bootloader
76 SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="0101", MODE="0664", GROUP="plugdev"
77 # Crazyflie (over USB)
78 SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"
79 EOF
80 '';
81
82 meta = {
83 description = "Python library for the Crazyflie quadcopter by Bitcraze";
84 homepage = "https://github.com/bitcraze/crazyflie-lib-python";
85 changelog = "https://github.com/bitcraze/crazyflie-lib-python/releases/tag/${version}";
86 license = lib.licenses.gpl2Only;
87 maintainers = [ lib.maintainers.brianmcgillion ];
88 platforms = lib.platforms.linux;
89 };
90}