summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyocd/default.nix
blob: 699b6c3cf553e05cd5ef4098009d6fc69f5e6407 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ lib
, buildPythonPackage
, fetchPypi
, fetchpatch
, capstone
, cmsis-pack-manager
, colorama
, intelhex
, intervaltree
, natsort
, prettytable
, pyelftools
, pylink-square
, pyusb
, pyyaml
, typing-extensions
, stdenv
, hidapi
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "pyocd";
  version = "0.34.3";

  src = fetchPypi {
    inherit pname version;
    sha256 = "2zDr6fnA2MCTT/hNVvk7u3gugMo+nUF2E2VsOPhJXH4=";
  };

  patches = [
    # https://github.com/pyocd/pyOCD/pull/1332
    (fetchpatch {
      name = "libusb-package-optional.patch";
      url = "https://github.com/pyocd/pyOCD/commit/0b980cf253e3714dd2eaf0bddeb7172d14089649.patch";
      hash = "sha256-B2+50VntcQELeakJbCeJdgI1iBU+h2NkXqba+LRYa/0=";
    })
  ];

  propagatedBuildInputs = [
    capstone
    cmsis-pack-manager
    colorama
    intelhex
    intervaltree
    natsort
    prettytable
    pyelftools
    pylink-square
    pyusb
    pyyaml
    typing-extensions
  ] ++ lib.optionals (!stdenv.isLinux) [
    hidapi
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "pyocd" ];

  postPatch = ''
    substituteInPlace setup.cfg \
        --replace "libusb-package>=1.0,<2.0" "" \
        --replace "pylink-square>=0.11.1,<1.0" "pylink-square>=0.11.1,<2.0"
  '';

  meta = with lib; {
    description = "Python library for programming and debugging Arm Cortex-M microcontrollers";
    homepage = "https://pyocd.io/";
    license = licenses.asl20;
    maintainers = with maintainers; [ frogamic sbruder ];
  };
}