1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchPypi,
6 pythonOlder,
7 dbus,
8 pkgsLibpcap,
9 pkg-about,
10 setuptools,
11 pytestCheckHook,
12}:
13
14buildPythonPackage rec {
15 pname = "libpcap";
16 version = "1.11.0b8";
17 format = "pyproject";
18
19 disabled = pythonOlder "3.7";
20
21 src = fetchPypi {
22 inherit pname version;
23 extension = "zip";
24 hash = "sha256-6XhEVOO2Z2rFZiMz4d32tTR+xUu1KdMdDjChmt2wsQo=";
25 };
26
27 nativeBuildInputs = [ setuptools ];
28
29 # tox is listed in build requirements but not actually used to build
30 # keeping it as a requirement breaks the build unnecessarily
31 postPatch = ''
32 sed -i "/requires/s/, 'tox>=[^']*'//" pyproject.toml
33 cat <<EOF >src/libpcap/libpcap.cfg
34 [libpcap]
35 LIBPCAP = ${pkgsLibpcap}/lib/libpcap${stdenv.hostPlatform.extensions.sharedLibrary}
36 EOF
37 '';
38
39 propagatedBuildInputs = [
40 dbus.lib
41 pkgsLibpcap
42 pkg-about
43 ];
44
45 preCheck = ''
46 pushd tests
47 '';
48 postCheck = ''
49 popd
50 '';
51 nativeCheckInputs = [ pytestCheckHook ];
52
53 pythonImportsCheck = [ "libpcap" ];
54
55 meta = with lib; {
56 description = "Python binding for the libpcap C library";
57 longDescription = ''
58 Python libpcap module is a low-level binding for libpcap C library.
59
60 It is an effort to allow python programs full access to the API provided by the well known libpcap Unix C library and by its implementations provided under Win32 systems by such packet capture systems as: Npcap, WinPcap
61
62 libpcap is a lightweight Python package, based on the ctypes library.
63
64 It is fully compliant implementation of the original C libpcap from 1.0.0 up to 1.9.0 API and the WinPcap’s 4.1.3 libpcap (1.0.0rel0b) API by implementing whole its functionality in a clean Python instead of C.
65 '';
66 homepage = "https://github.com/karpierz/libpcap/";
67 changelog = "https://github.com/karpierz/libpcap/blob/${version}/CHANGES.rst";
68 license = licenses.bsd3;
69 maintainers = teams.ororatech.members;
70 };
71}