1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, pythonOlder
6, dbus
7, pkgsLibpcap
8, pkg-about
9, setuptools
10}:
11
12buildPythonPackage rec {
13 pname = "libpcap";
14 version = "1.11.0b7";
15 format = "pyproject";
16
17 disabled = pythonOlder "3.7";
18
19 src = fetchPypi {
20 inherit pname version;
21 extension = "zip";
22 hash = "sha256-gEWFqmeOJTVHdjcSOxfVLZtrNSO3CTY1L2VcXOu7q7k=";
23 };
24
25 nativeBuildInputs = [
26 setuptools
27 ];
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>=3.25.1'//" 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 # Project has tests, but I can't get them to run even outside of nix
46 doCheck = false;
47
48 pythonImportsCheck = [
49 "libpcap"
50 ];
51
52 meta = with lib; {
53 description = "Python binding for the libpcap C library";
54 longDescription = ''
55 Python libpcap module is a low-level binding for libpcap C library.
56
57 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
58
59 libpcap is a lightweight Python package, based on the ctypes library.
60
61 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.
62 '';
63 homepage = "https://github.com/karpierz/libpcap/";
64 license = licenses.bsd3;
65 maintainers = [ teams.ororatech ];
66 };
67}