1{ lib
2, buildPythonPackage
3, dpkt
4, fetchFromGitHub
5, libpcap
6, pytestCheckHook
7}:
8
9buildPythonPackage rec {
10 pname = "pypcap";
11 version = "1.3.0";
12
13 src = fetchFromGitHub {
14 owner = "pynetwork";
15 repo = pname;
16 # No release was tagged and PyPI doesn't contain tests.
17 rev = "968859f0ffb5b7c990506dffe82457b7de23a026";
18 hash = "sha256-NfyEC3qEBm6TjebcDIsoz8tJWaJ625ZFPfx7AMyynWE=";
19 };
20
21 postPatch = ''
22 # Add the path to libpcap in the nix-store
23 substituteInPlace setup.py --replace "('/usr', sys.prefix)" "'${libpcap}'"
24 # Remove coverage from test run
25 sed -i "/--cov/d" setup.cfg
26 '';
27
28 buildInputs = [ libpcap ];
29
30 nativeCheckInputs = [
31 dpkt
32 pytestCheckHook
33 ];
34
35 pytestFlagsArray = [ "tests" ];
36
37 pythonImportsCheck = [ "pcap" ];
38
39 meta = with lib; {
40 homepage = "https://github.com/pynetwork/pypcap";
41 description = "Simplified object-oriented Python wrapper for libpcap";
42 license = licenses.bsd3;
43 maintainers = with maintainers; [ oxzi ];
44 };
45}