1{ lib, stdenv, buildPythonPackage, fetchPypi, isPy27, python
2, darwin
3, pytestCheckHook
4, mock
5, ipaddress
6, unittest2
7}:
8
9buildPythonPackage rec {
10 pname = "psutil";
11 version = "5.8.0";
12
13 src = fetchPypi {
14 inherit pname version;
15 sha256 = "1immnj532bnnrh1qmk5q3lsw3san8qfk9kxy1cpmy0knmfcwp70c";
16 };
17
18 # We have many test failures on various parts of the package:
19 # - segfaults on darwin:
20 # https://github.com/giampaolo/psutil/issues/1715
21 # - swap (on linux) might cause test failures if it is fully used:
22 # https://github.com/giampaolo/psutil/issues/1911
23 # - some mount paths are required in the build sanbox to make the tests succeed:
24 # https://github.com/giampaolo/psutil/issues/1912
25 doCheck = false;
26 checkInputs = [ pytestCheckHook ]
27 ++ lib.optionals isPy27 [ mock ipaddress unittest2 ];
28 # In addition to the issues listed above there are some that occure due to
29 # our sandboxing which we can work around by disabling some tests:
30 # - cpu_times was flaky on darwin
31 # - the other disabled tests are likely due to sanboxing (missing specific errors)
32 pytestFlagsArray = [
33 "$out/${python.sitePackages}/psutil/tests/test_system.py"
34 ];
35
36 # Note: $out must be referenced as test import paths are relative
37 disabledTests = [
38 "user"
39 "disk_io_counters"
40 "sensors_battery"
41 "cpu_times"
42 "cpu_freq"
43 ];
44
45 buildInputs = lib.optionals stdenv.isDarwin [ darwin.IOKit ];
46
47 pythonImportsCheck = [ "psutil" ];
48
49 meta = with lib; {
50 description = "Process and system utilization information interface for python";
51 homepage = "https://github.com/giampaolo/psutil";
52 license = licenses.bsd3;
53 maintainers = with maintainers; [ jonringer ];
54 };
55}