nixpkgs/pkgs/development/python-modules/psutil/default.nix

56 lines
1.7 KiB
Nix
Raw Normal View History

2020-02-22 04:22:10 +00:00
{ lib, stdenv, buildPythonPackage, fetchPypi, isPy27, python
, darwin
, pytestCheckHook
2020-02-22 04:22:10 +00:00
, mock
, ipaddress
2020-08-04 09:15:12 +00:00
, unittest2
}:
buildPythonPackage rec {
pname = "psutil";
2020-12-30 08:36:51 +00:00
version = "5.8.0";
src = fetchPypi {
inherit pname version;
2020-12-30 08:36:51 +00:00
sha256 = "1immnj532bnnrh1qmk5q3lsw3san8qfk9kxy1cpmy0knmfcwp70c";
};
pythonPackages.psutil: disable tests due to test failures Tests are very flaky and depend on the exact execution environment. It is weird that it has gone well so far but started causing issues across many of my builders. Also started rewording some of the comments in the expression so hopefully the next person looking at this has an easier time to understand it. On systems where swap is available and fully used tests fail like this: > def test_swap_memory(self): > mem = psutil.swap_memory() > self.assertEqual( > mem._fields, ('total', 'used', 'free', 'percent', 'sin', 'sout')) > > assert mem.total >= 0, mem > assert mem.used >= 0, mem > if mem.total > 0: > # likely a system with no swap partition > > assert mem.free > 0, mem > E AssertionError: sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040) > E assert 0 > 0 > E + where 0 = sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040).free Upstream bug report: https://github.com/giampaolo/psutil/issues/1911 Systems where /proc/mounts doesn't expose any mount points to build the tests fail like this: > def test_disk_partitions(self): > self.assertIsInstance(nt.device, str) > def check_ntuple(nt): > self.assertIsInstance(nt.mountpoint, str) > self.assertIsInstance(nt.fstype, str) > self.assertIsInstance(nt.opts, str) > self.assertIsInstance(nt.maxfile, (int, type(None))) > self.assertIsInstance(nt.maxpath, (int, type(None))) > self.assertGreater(nt.maxfile, 0) > if nt.maxfile is not None and not GITHUB_ACTIONS: > if nt.maxpath is not None: > self.assertGreater(nt.maxpath, 0) > > # all = False > ls = psutil.disk_partitions(all=False) > > self.assertTrue(ls, msg=ls) > E AssertionError: [] is not true : [] Upstream bug report: https://github.com/giampaolo/psutil/issues/1912
2021-01-31 17:31:13 +00:00
# We have many test failures on various parts of the package:
# - segfaults on darwin:
# https://github.com/giampaolo/psutil/issues/1715
# - swap (on linux) might cause test failures if it is fully used:
# https://github.com/giampaolo/psutil/issues/1911
# - some mount paths are required in the build sanbox to make the tests succeed:
# https://github.com/giampaolo/psutil/issues/1912
doCheck = false;
checkInputs = [ pytestCheckHook ]
pythonPackages.psutil: disable tests due to test failures Tests are very flaky and depend on the exact execution environment. It is weird that it has gone well so far but started causing issues across many of my builders. Also started rewording some of the comments in the expression so hopefully the next person looking at this has an easier time to understand it. On systems where swap is available and fully used tests fail like this: > def test_swap_memory(self): > mem = psutil.swap_memory() > self.assertEqual( > mem._fields, ('total', 'used', 'free', 'percent', 'sin', 'sout')) > > assert mem.total >= 0, mem > assert mem.used >= 0, mem > if mem.total > 0: > # likely a system with no swap partition > > assert mem.free > 0, mem > E AssertionError: sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040) > E assert 0 > 0 > E + where 0 = sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040).free Upstream bug report: https://github.com/giampaolo/psutil/issues/1911 Systems where /proc/mounts doesn't expose any mount points to build the tests fail like this: > def test_disk_partitions(self): > self.assertIsInstance(nt.device, str) > def check_ntuple(nt): > self.assertIsInstance(nt.mountpoint, str) > self.assertIsInstance(nt.fstype, str) > self.assertIsInstance(nt.opts, str) > self.assertIsInstance(nt.maxfile, (int, type(None))) > self.assertIsInstance(nt.maxpath, (int, type(None))) > self.assertGreater(nt.maxfile, 0) > if nt.maxfile is not None and not GITHUB_ACTIONS: > if nt.maxpath is not None: > self.assertGreater(nt.maxpath, 0) > > # all = False > ls = psutil.disk_partitions(all=False) > > self.assertTrue(ls, msg=ls) > E AssertionError: [] is not true : [] Upstream bug report: https://github.com/giampaolo/psutil/issues/1912
2021-01-31 17:31:13 +00:00
++ lib.optionals isPy27 [ mock ipaddress unittest2 ];
# In addition to the issues listed above there are some that occure due to
# our sandboxing which we can work around by disabling some tests:
# - cpu_times was flaky on darwin
# - the other disabled tests are likely due to sanboxing (missing specific errors)
pytestFlagsArray = [
"$out/${python.sitePackages}/psutil/tests/test_system.py"
];
pythonPackages.psutil: disable tests due to test failures Tests are very flaky and depend on the exact execution environment. It is weird that it has gone well so far but started causing issues across many of my builders. Also started rewording some of the comments in the expression so hopefully the next person looking at this has an easier time to understand it. On systems where swap is available and fully used tests fail like this: > def test_swap_memory(self): > mem = psutil.swap_memory() > self.assertEqual( > mem._fields, ('total', 'used', 'free', 'percent', 'sin', 'sout')) > > assert mem.total >= 0, mem > assert mem.used >= 0, mem > if mem.total > 0: > # likely a system with no swap partition > > assert mem.free > 0, mem > E AssertionError: sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040) > E assert 0 > 0 > E + where 0 = sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040).free Upstream bug report: https://github.com/giampaolo/psutil/issues/1911 Systems where /proc/mounts doesn't expose any mount points to build the tests fail like this: > def test_disk_partitions(self): > self.assertIsInstance(nt.device, str) > def check_ntuple(nt): > self.assertIsInstance(nt.mountpoint, str) > self.assertIsInstance(nt.fstype, str) > self.assertIsInstance(nt.opts, str) > self.assertIsInstance(nt.maxfile, (int, type(None))) > self.assertIsInstance(nt.maxpath, (int, type(None))) > self.assertGreater(nt.maxfile, 0) > if nt.maxfile is not None and not GITHUB_ACTIONS: > if nt.maxpath is not None: > self.assertGreater(nt.maxpath, 0) > > # all = False > ls = psutil.disk_partitions(all=False) > > self.assertTrue(ls, msg=ls) > E AssertionError: [] is not true : [] Upstream bug report: https://github.com/giampaolo/psutil/issues/1912
2021-01-31 17:31:13 +00:00
# Note: $out must be referenced as test import paths are relative
disabledTests = [
"user"
"disk_io_counters"
"sensors_battery"
"cpu_times"
"cpu_freq"
];
2020-02-22 04:22:10 +00:00
buildInputs = lib.optionals stdenv.isDarwin [ darwin.IOKit ];
2020-02-22 04:22:10 +00:00
pythonImportsCheck = [ "psutil" ];
meta = with lib; {
description = "Process and system utilization information interface for python";
2020-02-22 04:22:10 +00:00
homepage = "https://github.com/giampaolo/psutil";
license = licenses.bsd3;
maintainers = with maintainers; [ jonringer ];
};
}