1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 capstone,
7 cmsis-pack-manager,
8 colorama,
9 importlib-metadata,
10 importlib-resources,
11 intelhex,
12 intervaltree,
13 lark,
14 natsort,
15 prettytable,
16 pyelftools,
17 pylink-square,
18 pyusb,
19 pyyaml,
20 setuptools-scm,
21 typing-extensions,
22 stdenv,
23 hidapi,
24 pytestCheckHook,
25}:
26
27buildPythonPackage rec {
28 pname = "pyocd";
29 version = "0.36.0";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "pyocd";
34 repo = "pyOCD";
35 tag = "v${version}";
36 hash = "sha256-CSdVWDiSe+xd0MzD9tsKs3DklNjnhchYFuI3Udi0O20=";
37 };
38
39 patches = [
40 # https://github.com/pyocd/pyOCD/pull/1332
41 # merged into develop
42 (fetchpatch {
43 name = "libusb-package-optional.patch";
44 url = "https://github.com/pyocd/pyOCD/commit/0b980cf253e3714dd2eaf0bddeb7172d14089649.patch";
45 hash = "sha256-B2+50VntcQELeakJbCeJdgI1iBU+h2NkXqba+LRYa/0=";
46 })
47 ];
48
49 pythonRelaxDeps = [ "capstone" ];
50 pythonRemoveDeps = [ "libusb-package" ];
51
52 build-system = [ setuptools-scm ];
53
54 dependencies = [
55 capstone
56 cmsis-pack-manager
57 colorama
58 importlib-metadata
59 importlib-resources
60 intelhex
61 intervaltree
62 lark
63 natsort
64 prettytable
65 pyelftools
66 pylink-square
67 pyusb
68 pyyaml
69 typing-extensions
70 ] ++ lib.optionals (!stdenv.hostPlatform.isLinux) [ hidapi ];
71
72 pythonImportsCheck = [ "pyocd" ];
73
74 disabledTests = [
75 # AttributeError: 'not_called' is not a valid assertion
76 # Upstream fix at https://github.com/pyocd/pyOCD/pull/1710
77 "test_transfer_err_not_flushed"
78 ];
79
80 nativeCheckInputs = [ pytestCheckHook ];
81
82 meta = with lib; {
83 changelog = "https://github.com/pyocd/pyOCD/releases/tag/v${version}";
84 description = "Python library for programming and debugging Arm Cortex-M microcontrollers";
85 downloadPage = "https://github.com/pyocd/pyOCD";
86 homepage = "https://pyocd.io";
87 license = licenses.asl20;
88 maintainers = with maintainers; [
89 frogamic
90 sbruder
91 ];
92 };
93}