summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyshark/default.nix
blob: edc5bd5c70607a45446907d6bbd44320ae4e8463 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
  lib,
  stdenv,
  appdirs,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  lxml,
  packaging,
  pytestCheckHook,
  replaceVars,
  setuptools,
  termcolor,
  wireshark-cli,
}:

buildPythonPackage rec {
  pname = "pyshark";
  version = "0.6";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "KimiNewt";
    repo = "pyshark";
    tag = "v${version}";
    hash = "sha256-kzJDzUK6zknUyXPdKc4zMvWim4C5NQCSJSS45HI6hKM=";
  };

  # `stripLen` does not seem to work here
  patchFlags = [ "-p2" ];

  patches = [
    # fixes capture test
    (fetchpatch {
      url = "https://github.com/KimiNewt/pyshark/commit/7142c5bf88abcd4c65c81052a00226d6155dda42.patch";
      hash = "sha256-Ti7cwRyYSbF4a4pEEV9FntNevkV/JVXNqACQWzoma7g=";
    })
    # fixes tests that failed related to elastic-mapping
    # remove fix if this is ever merged upstream
    (fetchpatch {
      url = "https://github.com/KimiNewt/pyshark/commit/0e1d8d0e06108f2887c3147c93049de63b475f8a.patch";
      hash = "sha256-fpgiBHcfS/TGYIB65ioZJrWUuDIrLxxXqGVJ9y18b2w=";
    })
    (replaceVars ./hardcode-tshark-path.patch {
      tshark = lib.getExe' wireshark-cli "tshark";
    })
  ];

  sourceRoot = "${src.name}/src";

  build-system = [ setuptools ];

  dependencies = [
    appdirs
    lxml
    packaging
    termcolor
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  preCheck = ''
    export HOME=$(mktemp -d)
  '';

  disabledTests = [
    # flaky
    # KeyError: 'Packet of index 0 does not exist in capture'
    "test_getting_packet_summary"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # fails on darwin
    # _pickle.PicklingError: logger cannot be pickled
    "test_iterate_empty_psml_capture"
  ];

  pythonImportsCheck = [ "pyshark" ];

  enabledTestPaths = [ "../tests/" ];

  meta = {
    description = "Python wrapper for tshark, allowing Python packet parsing using Wireshark dissectors";
    homepage = "https://github.com/KimiNewt/pyshark/";
    changelog = "https://github.com/KimiNewt/pyshark/releases/tag/${version}";
    license = lib.licenses.mit;
    maintainers = [ ];
  };
}