1{ lib, writeText, buildPythonPackage, fetchPypi, libpcap, dpkt }:
2
3buildPythonPackage rec {
4 pname = "pypcap";
5 version = "1.2.2";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "07ww25z4xydp11hb38halh1940gmp5lca11hwfb63zv3bps248x3";
10 };
11
12 patches = [
13 # The default setup.py searchs for pcap.h in a static list of default
14 # folders. So we have to add the path to libpcap in the nix-store.
15 (writeText "libpcap-path.patch"
16 ''
17 --- a/setup.py
18 +++ b/setup.py
19 @@ -28,6 +28,7 @@ def recursive_search(path, target_files):
20
21 def find_prefix_and_pcap_h():
22 prefixes = chain.from_iterable((
23 + '${libpcap}',
24 ('/usr', sys.prefix),
25 glob.glob('/opt/libpcap*'),
26 glob.glob('../libpcap*'),
27 '')
28 ];
29
30 buildInputs = [ libpcap ];
31 checkInputs = [ dpkt ];
32
33 meta = with lib; {
34 homepage = https://github.com/pynetwork/pypcap;
35 description = "Simplified object-oriented Python wrapper for libpcap";
36 license = licenses.bsd3;
37 maintainers = with maintainers; [ geistesk ];
38 };
39}