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,
21 setuptools-scm,
22 typing-extensions,
23 stdenv,
24 hidapi,
25 pytestCheckHook,
26}:
27
28buildPythonPackage rec {
29 pname = "pyocd";
30 version = "0.36.0";
31 pyproject = true;
32
33 src = fetchPypi {
34 inherit pname version;
35 hash = "sha256-k3eCrMna/wVNUPt8b3iM2UqE+A8LhfJarKuZ3Jgihkg=";
36 };
37
38 patches = [
39 # https://github.com/pyocd/pyOCD/pull/1332
40 (fetchpatch {
41 name = "libusb-package-optional.patch";
42 url = "https://github.com/pyocd/pyOCD/commit/0b980cf253e3714dd2eaf0bddeb7172d14089649.patch";
43 hash = "sha256-B2+50VntcQELeakJbCeJdgI1iBU+h2NkXqba+LRYa/0=";
44 })
45 ];
46
47 postPatch = ''
48 substituteInPlace setup.cfg \
49 --replace "libusb-package>=1.0,<2.0" ""
50 '';
51
52 nativeBuildInputs = [
53 setuptools
54 setuptools-scm
55 ];
56
57 propagatedBuildInputs = [
58 capstone_4
59 cmsis-pack-manager
60 colorama
61 importlib-metadata
62 importlib-resources
63 intelhex
64 intervaltree
65 lark
66 natsort
67 prettytable
68 pyelftools
69 pylink-square
70 pyusb
71 pyyaml
72 typing-extensions
73 ] ++ lib.optionals (!stdenv.isLinux) [ hidapi ];
74
75 pythonImportsCheck = [ "pyocd" ];
76
77 nativeCheckInputs = [ pytestCheckHook ];
78
79 meta = with lib; {
80 changelog = "https://github.com/pyocd/pyOCD/releases/tag/v${version}";
81 description = "Python library for programming and debugging Arm Cortex-M microcontrollers";
82 downloadPage = "https://github.com/pyocd/pyOCD";
83 homepage = "https://pyocd.io";
84 license = licenses.asl20;
85 maintainers = with maintainers; [
86 frogamic
87 sbruder
88 ];
89 };
90}