Commit 026dd53d authored by Robert Schütz's avatar Robert Schütz
Browse files

python312Packages.ethtool: fix tests

parent 78b9e2d7
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -2,32 +2,54 @@
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch2,
  setuptools,
  pkg-config,
  libnl,
  nettools,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "ethtool";
  version = "0.15";
  format = "setuptools";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "fedora-python";
    repo = "python-ethtool";
    rev = "v${version}";
    sha256 = "0arkcfq64a4fl88vjjsx4gd3mhcpa7mpq6sblpkgs4k4m9mccz6i";
    rev = "refs/tags/v${version}";
    hash = "sha256-0XzGaqpkEv3mpUsbfOtRl8E62iNdS7kRoo4oYrBjMys=";
  };

  patches = [
    # https://github.com/fedora-python/python-ethtool/pull/60
    (fetchpatch2 {
      url = "https://github.com/fedora-python/python-ethtool/commit/f82dd763bd50affda993b9afe3b141069a1a7466.patch";
      hash = "sha256-mtI7XsoyM43s2DFQdsBNpB8jJff7ZyO2J6SHodBrdrI=";
    })
  ];

  postPatch = ''
    substituteInPlace tests/parse_ifconfig.py --replace "Popen('ifconfig'," "Popen('${nettools}/bin/ifconfig',"
    substituteInPlace tests/parse_ifconfig.py \
      --replace-fail "Popen('ifconfig'," "Popen('${lib.getExe' nettools "ifconfig"}',"
  '';

  buildInputs = [ libnl ];
  build-system = [ setuptools ];

  nativeBuildInputs = [ pkg-config ];

  buildInputs = [ libnl ];

  pythonImportsCheck = [ "ethtool" ];

  nativeCheckInputs = [
    nettools
    pytestCheckHook
  ];

  meta = with lib; {
    changelog = "https://github.com/fedora-python/python-ethtool/blob/${src.rev}/CHANGES.rst";
    description = "Python bindings for the ethtool kernel interface";
    homepage = "https://github.com/fedora-python/python-ethtool";
    license = licenses.gpl2Plus;