nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchPypi,
6 dbus,
7 pkgsLibpcap,
8 pkg-about,
9 setuptools,
10 pytestCheckHook,
11}:
12
13buildPythonPackage rec {
14 pname = "libpcap";
15 version = "1.11.0b25";
16 pyproject = true;
17
18 src = fetchPypi {
19 inherit pname version;
20 hash = "sha256-GzrTqpkiKJjWBuZ7ez707BGZez9wXB96psygDQykO6c=";
21 };
22
23 build-system = [ setuptools ];
24
25 # tox is listed in build requirements but not actually used to build
26 # keeping it as a requirement breaks the build unnecessarily
27 postPatch = ''
28 sed -i "/requires/s/, 'tox>=[^']*'//" pyproject.toml
29 cat <<EOF >src/libpcap/libpcap.cfg
30 [libpcap]
31 LIBPCAP = ${lib.getLib pkgsLibpcap}/lib/libpcap${stdenv.hostPlatform.extensions.sharedLibrary}
32 EOF
33 '';
34
35 buildInputs = [
36 dbus.lib
37 pkgsLibpcap
38 pkg-about
39 ];
40
41 preCheck = ''
42 pushd tests
43 '';
44 postCheck = ''
45 popd
46 '';
47 nativeCheckInputs = [ pytestCheckHook ];
48
49 pythonImportsCheck = [ "libpcap" ];
50
51 meta = {
52 description = "Python binding for the libpcap C library";
53 longDescription = ''
54 Python libpcap module is a low-level binding for libpcap C library.
55
56 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
57
58 libpcap is a lightweight Python package, based on the ctypes library.
59
60 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.
61 '';
62 homepage = "https://github.com/karpierz/libpcap/";
63 changelog = "https://github.com/karpierz/libpcap/blob/${version}/CHANGES.rst";
64 license = lib.licenses.bsd3;
65 };
66}