2021-02-14 10:22:00 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, dpkt
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, libpcap
|
|
|
|
, pytestCheckHook
|
|
|
|
}:
|
2017-10-08 18:13:36 +01:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pypcap";
|
2019-08-05 16:16:11 +01:00
|
|
|
version = "1.2.3";
|
2017-10-08 18:13:36 +01:00
|
|
|
|
2021-02-14 10:22:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pynetwork";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1zscfk10jpqwxgc8d84y8bffiwr92qrg2b24afhjwiyr352l67cf";
|
2017-10-08 18:13:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
2021-02-14 10:22:00 +00:00
|
|
|
# Support for Python 3.9, https://github.com/pynetwork/pypcap/pull/102
|
|
|
|
(fetchpatch {
|
|
|
|
name = "support-python-3.9.patch";
|
|
|
|
url = "https://github.com/pynetwork/pypcap/pull/102/commits/e22f5d25f0d581d19ef337493434e72cd3a6ae71.patch";
|
|
|
|
sha256 = "0n1syh1vcplgsf6njincpqphd2w030s3b2jyg86d7kbqv1w5wk0l";
|
|
|
|
})
|
2017-10-08 18:13:36 +01:00
|
|
|
];
|
|
|
|
|
2021-02-14 10:22:00 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2017-11-16 08:22:11 +00:00
|
|
|
buildInputs = [ libpcap ];
|
2021-02-14 10:22:00 +00:00
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
dpkt
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
|
|
|
pytestFlagsArray = [ "tests" ];
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "pcap" ];
|
2017-10-08 18:13:36 +01:00
|
|
|
|
2018-05-21 20:53:50 +01:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/pynetwork/pypcap";
|
2017-10-08 18:13:36 +01:00
|
|
|
description = "Simplified object-oriented Python wrapper for libpcap";
|
2018-05-21 20:53:50 +01:00
|
|
|
license = licenses.bsd3;
|
2020-08-15 14:25:59 +01:00
|
|
|
maintainers = with maintainers; [ oxzi ];
|
2017-10-08 18:13:36 +01:00
|
|
|
};
|
|
|
|
}
|