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