From 6268a5fdf239e4cca6c91ae649cc2611702f98a4 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 12 Apr 2024 13:02:40 +0200 Subject: [PATCH 1/2] python312Packages.batinfo: refactor - enable tests - add pythonImportsCheck --- .../python-modules/batinfo/default.nix | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/pkgs/development/python-modules/batinfo/default.nix b/pkgs/development/python-modules/batinfo/default.nix index c4fdc9ee92cf..bd8af6fbbf7e 100644 --- a/pkgs/development/python-modules/batinfo/default.nix +++ b/pkgs/development/python-modules/batinfo/default.nix @@ -1,23 +1,54 @@ -{ lib, buildPythonPackage, fetchPypi }: +{ lib +, buildPythonPackage +, fetchFromGitHub +, pytestCheckHook +, pythonOlder +, setuptools +}: buildPythonPackage rec { pname = "batinfo"; version = "0.4.2"; - format = "setuptools"; + pyproject = true; - src = fetchPypi { - inherit pname version; - sha256 = "497e29efc9353ec52e71d43bd040bdfb6d685137ddc2b9143cded4583af572f5"; + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "nicolargo"; + repo = "batinfo"; + rev = "refs/tags/v${version}"; + hash = "sha256-GgAJJA8bzQJLAU+nxmkDa5LFTHc4NGi+nj9PfKyw8/M="; }; - # No tests included - doCheck = false; + postPatch = '' + substituteInPlace test_batinfo.py \ + --replace-fail "self.assertEquals" "self.assertEqual" + ''; + + build-system = [ + setuptools + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + pythonImportsCheck = [ + "batinfo" + ]; + + disabledTests = [ + # Tests are a bit outdated + "test_batinfo_capacity" + "test_batinfo_charge_now" + "test_batinfo_name_default" + ]; meta = with lib; { + description = "Module to retrieve battery information"; homepage = "https://github.com/nicolargo/batinfo"; - description = "A simple Python lib to retrieve battery information"; - license = licenses.lgpl3; - platforms = platforms.linux; + license = licenses.lgpl3Plus; maintainers = with maintainers; [ koral ]; + platforms = platforms.linux; }; } From 13251c32947e0cf454f714c8e3766a8ca1efb91f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 12 Apr 2024 13:03:19 +0200 Subject: [PATCH 2/2] python312Packages.batinfo: format with nixfmt --- .../python-modules/batinfo/default.nix | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/pkgs/development/python-modules/batinfo/default.nix b/pkgs/development/python-modules/batinfo/default.nix index bd8af6fbbf7e..cfe0b5d35680 100644 --- a/pkgs/development/python-modules/batinfo/default.nix +++ b/pkgs/development/python-modules/batinfo/default.nix @@ -1,9 +1,10 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, pytestCheckHook -, pythonOlder -, setuptools +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + pythonOlder, + setuptools, }: buildPythonPackage rec { @@ -25,17 +26,11 @@ buildPythonPackage rec { --replace-fail "self.assertEquals" "self.assertEqual" ''; - build-system = [ - setuptools - ]; + build-system = [ setuptools ]; - nativeCheckInputs = [ - pytestCheckHook - ]; + nativeCheckInputs = [ pytestCheckHook ]; - pythonImportsCheck = [ - "batinfo" - ]; + pythonImportsCheck = [ "batinfo" ]; disabledTests = [ # Tests are a bit outdated