1{ lib
2, buildPythonPackage
3, fetchPypi
4, fetchpatch
5, capstone
6, cmsis-pack-manager
7, colorama
8, intelhex
9, intervaltree
10, natsort
11, prettytable
12, pyelftools
13, pylink-square
14, pyusb
15, pyyaml
16, typing-extensions
17, stdenv
18, hidapi
19, pytestCheckHook
20}:
21
22buildPythonPackage rec {
23 pname = "pyocd";
24 version = "0.34.3";
25
26 src = fetchPypi {
27 inherit pname version;
28 sha256 = "2zDr6fnA2MCTT/hNVvk7u3gugMo+nUF2E2VsOPhJXH4=";
29 };
30
31 patches = [
32 # https://github.com/pyocd/pyOCD/pull/1332
33 (fetchpatch {
34 name = "libusb-package-optional.patch";
35 url = "https://github.com/pyocd/pyOCD/commit/0b980cf253e3714dd2eaf0bddeb7172d14089649.patch";
36 hash = "sha256-B2+50VntcQELeakJbCeJdgI1iBU+h2NkXqba+LRYa/0=";
37 })
38 ];
39
40 propagatedBuildInputs = [
41 capstone
42 cmsis-pack-manager
43 colorama
44 intelhex
45 intervaltree
46 natsort
47 prettytable
48 pyelftools
49 pylink-square
50 pyusb
51 pyyaml
52 typing-extensions
53 ] ++ lib.optionals (!stdenv.isLinux) [
54 hidapi
55 ];
56
57 nativeCheckInputs = [ pytestCheckHook ];
58
59 pythonImportsCheck = [ "pyocd" ];
60
61 postPatch = ''
62 substituteInPlace setup.cfg \
63 --replace "libusb-package>=1.0,<2.0" "" \
64 --replace "pylink-square>=0.11.1,<1.0" "pylink-square>=0.11.1,<2.0"
65 '';
66
67 meta = with lib; {
68 description = "Python library for programming and debugging Arm Cortex-M microcontrollers";
69 homepage = "https://pyocd.io/";
70 license = licenses.asl20;
71 maintainers = with maintainers; [ frogamic sbruder ];
72 };
73}