Merge pull request #276123 from alaviss/nftables-py

nftables: split python package from main
This commit is contained in:
Sandro 2024-04-21 19:21:38 +02:00 committed by GitHub
commit 77d99f85c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 32 deletions

View File

@ -5,7 +5,6 @@
, autoreconfHook
, withDebugSymbols ? false
, withCli ? true, libedit
, withPython ? false, python3
, withXtables ? true, iptables
, nixosTests
}:
@ -29,25 +28,12 @@ stdenv.mkDerivation rec {
libmnl libnftnl libpcap
gmp jansson
] ++ lib.optional withCli libedit
++ lib.optional withXtables iptables
++ lib.optionals withPython [
python3
python3.pkgs.setuptools
];
patches = [ ./fix-py-libnftables.patch ];
postPatch = ''
substituteInPlace "py/src/nftables.py" \
--subst-var-by "out" "$out"
'';
++ lib.optional withXtables iptables;
configureFlags = [
"--with-json"
(lib.withFeatureAs withCli "cli" "editline")
] ++ lib.optional (!withDebugSymbols) "--disable-debug"
++ lib.optional (!withPython) "--disable-python"
++ lib.optional withPython "--enable-python"
++ lib.optional withXtables "--with-xtables";
passthru.tests = {

View File

@ -1,13 +0,0 @@
diff --git a/py/src/nftables.py b/py/src/nftables.py
index f1e43ade..9adcd1be 100644
--- a/py/src/nftables.py
+++ b/py/src/nftables.py
@@ -69,7 +69,7 @@ class Nftables:
validator = None
- def __init__(self, sofile="libnftables.so.1"):
+ def __init__(self, sofile="@out@/lib/libnftables.so.1"):
"""Instantiate a new Nftables class object.
Accepts a shared object file to open, by default standard search path

View File

@ -0,0 +1,26 @@
{ lib
, buildPythonPackage
, setuptools
, nftables
}:
buildPythonPackage {
pname = "nftables";
inherit (nftables) version src;
pyproject = true;
postPatch = ''
substituteInPlace "py/src/nftables.py" \
--replace-fail "libnftables.so.1" "${nftables}/lib/libnftables.so.1"
'';
setSourceRoot = "sourceRoot=$(echo */py)";
build-system = [ setuptools ];
pythonImportsCheck = [ "nftables" ];
meta = {
inherit (nftables.meta) description homepage license platforms maintainers;
};
}

View File

@ -8684,10 +8684,9 @@ self: super: with self; {
nfcpy = callPackage ../development/python-modules/nfcpy { };
nftables = toPythonModule (pkgs.nftables.override {
python3 = python;
withPython = true;
});
nftables = callPackage ../os-specific/linux/nftables/python.nix {
inherit (pkgs) nftables;
};
nh3 = callPackage ../development/python-modules/nh3 { };