1{ lib
2, stdenv
3, buildPythonPackage
4, CoreFoundation
5, fetchPypi
6, IOKit
7, pytestCheckHook
8, python
9, pythonOlder
10}:
11
12buildPythonPackage rec {
13 pname = "psutil";
14 version = "5.9.3";
15 format = "setuptools";
16
17 disabled = pythonOlder "3.7";
18
19 src = fetchPypi {
20 inherit pname version;
21 hash = "sha256-fM/N/qT8SwoCyiwx3n/NGGvrnP+CB4AOFKtm95x3OvY=";
22 };
23
24 buildInputs =
25 # workaround for https://github.com/NixOS/nixpkgs/issues/146760
26 lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
27 CoreFoundation
28 ] ++ lib.optionals stdenv.isDarwin [
29 IOKit
30 ];
31
32 checkInputs = [
33 pytestCheckHook
34 ];
35
36 # Segfaults on darwin:
37 # https://github.com/giampaolo/psutil/issues/1715
38 doCheck = !stdenv.isDarwin;
39
40 # In addition to the issues listed above there are some that occure due to
41 # our sandboxing which we can work around by disabling some tests:
42 # - cpu_times was flaky on darwin
43 # - the other disabled tests are likely due to sanboxing (missing specific errors)
44 pytestFlagsArray = [
45 "$out/${python.sitePackages}/psutil/tests/test_system.py"
46 ];
47
48 # Note: $out must be referenced as test import paths are relative
49 disabledTests = [
50 "cpu_freq"
51 "cpu_times"
52 "disk_io_counters"
53 "sensors_battery"
54 "user"
55 ];
56
57 pythonImportsCheck = [
58 "psutil"
59 ];
60
61 meta = with lib; {
62 description = "Process and system utilization information interface";
63 homepage = "https://github.com/giampaolo/psutil";
64 license = licenses.bsd3;
65 maintainers = with maintainers; [ jonringer ];
66 };
67}