1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, fetchpatch
6, appdirs
7, lxml
8, packaging
9, py
10, pytestCheckHook
11, wireshark-cli
12, stdenv
13}:
14
15buildPythonPackage rec {
16 pname = "pyshark";
17 version = "0.5.3";
18 format = "setuptools";
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchFromGitHub {
23 owner = "KimiNewt";
24 repo = pname;
25 rev = "refs/tags/v${version}";
26 hash = "sha256-byll2GWY2841AAf8Xh+KfaCOtMGVKabTsLCe3gCdZ1o=";
27 };
28
29 patches = [
30 (fetchpatch {
31 name = "fix-mapping.patch";
32 url =
33 "https://github.com/KimiNewt/pyshark/pull/608/commits/c2feb17ef621390481d6acc29dbf807d6851ed4c.patch";
34 hash = "sha256-TY09HPxqJP3zI8+ugm518aMuBgog7wrXs5uoReHHaEI=";
35 })
36 ];
37
38 # `stripLen` does not seem to work here
39 patchFlags = [ "-p2" ];
40
41 sourceRoot = "${src.name}/src";
42
43 # propagate wireshark, so pyshark can find it when used
44 propagatedBuildInputs = [ appdirs py lxml packaging wireshark-cli ];
45
46 preCheck = ''
47 export HOME=$(mktemp -d)
48 '';
49
50 nativeCheckInputs = [ py pytestCheckHook wireshark-cli ];
51
52 disabledTests = [
53 # flaky
54 # KeyError: 'Packet of index 0 does not exist in capture'
55 "test_getting_packet_summary"
56 ] ++ lib.optionals stdenv.isDarwin [
57 # fails on darwin
58 # _pickle.PicklingError: logger cannot be pickled
59 "test_iterate_empty_psml_capture"
60 ];
61
62 pythonImportsCheck = [ "pyshark" ];
63
64 pytestFlagsArray = [ "../tests/" ];
65
66 meta = with lib; {
67 description =
68 "Python wrapper for tshark, allowing Python packet parsing using Wireshark dissectors";
69 homepage = "https://github.com/KimiNewt/pyshark/";
70 license = licenses.mit;
71 maintainers = with maintainers; [ ];
72 };
73}