about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pypcap/default.nix
blob: 77d27bdff1e5a1f1aab7b373ecebe476265221aa (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
{ lib
, buildPythonPackage
, dpkt
, fetchFromGitHub
, libpcap
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "pypcap";
  version = "1.3.0";

  src = fetchFromGitHub {
    owner = "pynetwork";
    repo = pname;
    # No release was tagged and PyPI doesn't contain tests.
    rev = "968859f0ffb5b7c990506dffe82457b7de23a026";
    sha256 = "sha256-NfyEC3qEBm6TjebcDIsoz8tJWaJ625ZFPfx7AMyynWE=";
  };

  postPatch = ''
    # Add the path to libpcap in the nix-store
    substituteInPlace setup.py --replace "('/usr', sys.prefix)" "'${libpcap}'"
    # Remove coverage from test run
    sed -i "/--cov/d" setup.cfg
  '';

  buildInputs = [ libpcap ];

  nativeCheckInputs = [
    dpkt
    pytestCheckHook
  ];

  pytestFlagsArray = [ "tests" ];

  pythonImportsCheck = [ "pcap" ];

  meta = with lib; {
    homepage = "https://github.com/pynetwork/pypcap";
    description = "Simplified object-oriented Python wrapper for libpcap";
    license = licenses.bsd3;
    maintainers = with maintainers; [ oxzi ];
  };
}