1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 fetchpatch,
6 capstone_4,
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 = fetchPypi {
33 inherit pname version;
34 hash = "sha256-k3eCrMna/wVNUPt8b3iM2UqE+A8LhfJarKuZ3Jgihkg=";
35 };
36
37 patches = [
38 # https://github.com/pyocd/pyOCD/pull/1332
39 (fetchpatch {
40 name = "libusb-package-optional.patch";
41 url = "https://github.com/pyocd/pyOCD/commit/0b980cf253e3714dd2eaf0bddeb7172d14089649.patch";
42 hash = "sha256-B2+50VntcQELeakJbCeJdgI1iBU+h2NkXqba+LRYa/0=";
43 })
44 ];
45
46 pythonRemoveDeps = [ "libusb-package" ];
47
48 build-system = [ setuptools-scm ];
49
50 dependencies = [
51 capstone_4
52 cmsis-pack-manager
53 colorama
54 importlib-metadata
55 importlib-resources
56 intelhex
57 intervaltree
58 lark
59 natsort
60 prettytable
61 pyelftools
62 pylink-square
63 pyusb
64 pyyaml
65 typing-extensions
66 ] ++ lib.optionals (!stdenv.isLinux) [ hidapi ];
67
68 pythonImportsCheck = [ "pyocd" ];
69
70 disabledTests = [
71 # AttributeError: 'not_called' is not a valid assertion
72 # Upstream fix at https://github.com/pyocd/pyOCD/pull/1710
73 "test_transfer_err_not_flushed"
74 ];
75
76 nativeCheckInputs = [ pytestCheckHook ];
77
78 meta = with lib; {
79 changelog = "https://github.com/pyocd/pyOCD/releases/tag/v${version}";
80 description = "Python library for programming and debugging Arm Cortex-M microcontrollers";
81 downloadPage = "https://github.com/pyocd/pyOCD";
82 homepage = "https://pyocd.io";
83 license = licenses.asl20;
84 maintainers = with maintainers; [
85 frogamic
86 sbruder
87 ];
88 };
89}