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.5";
15 format = "setuptools";
16
17 disabled = pythonOlder "3.7";
18
19 src = fetchPypi {
20 inherit pname version;
21 hash = "sha256-VBBjjk3znFTZV/xRzgMEis2ObWCrwPUQevUeX7Vm6zw=";
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 nativeCheckInputs = [
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 # Note: $out must be referenced as test import paths are relative
46 "$out/${python.sitePackages}/psutil/tests/test_system.py"
47 ];
48
49 disabledTests = [
50 # Some of the tests have build-system hardware-based impurities (like
51 # reading temperature sensor values). Disable them to avoid the failures
52 # that sometimes result.
53 "cpu_freq"
54 "cpu_times"
55 "disk_io_counters"
56 "sensors_battery"
57 "sensors_temperatures"
58 "user"
59 "test_disk_partitions" # problematic on Hydra's Linux builders, apparently
60 ];
61
62 pythonImportsCheck = [
63 "psutil"
64 ];
65
66 meta = with lib; {
67 description = "Process and system utilization information interface";
68 homepage = "https://github.com/giampaolo/psutil";
69 changelog = "https://github.com/giampaolo/psutil/blob/release-${version}/HISTORY.rst";
70 license = licenses.bsd3;
71 maintainers = with maintainers; [ jonringer ];
72 };
73}