1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchPypi,
6 setuptools,
7 pytestCheckHook,
8 python,
9 pythonOlder,
10}:
11
12buildPythonPackage rec {
13 pname = "psutil";
14 version = "7.0.0";
15 pyproject = true;
16
17 inherit stdenv;
18
19 disabled = pythonOlder "3.7";
20
21 src = fetchPypi {
22 inherit pname version;
23 hash = "sha256-e+nD66OL7Mtkleozr9mCpEB0t48oxDSh9RzAf9MVxFY=";
24 };
25
26 postPatch = ''
27 # stick to the old SDK name for now
28 # https://developer.apple.com/documentation/iokit/kiomasterportdefault/
29 # https://developer.apple.com/documentation/iokit/kiomainportdefault/
30 substituteInPlace psutil/arch/osx/cpu.c \
31 --replace-fail kIOMainPortDefault kIOMasterPortDefault
32 '';
33
34 build-system = [ setuptools ];
35
36 nativeCheckInputs = [ pytestCheckHook ];
37
38 # Segfaults on darwin:
39 # https://github.com/giampaolo/psutil/issues/1715
40 doCheck = !stdenv.hostPlatform.isDarwin;
41
42 # In addition to the issues listed above there are some that occure due to
43 # our sandboxing which we can work around by disabling some tests:
44 # - cpu_times was flaky on darwin
45 # - the other disabled tests are likely due to sandboxing (missing specific errors)
46 enabledTestPaths = [
47 # Note: $out must be referenced as test import paths are relative
48 "${placeholder "out"}/${python.sitePackages}/psutil/tests/test_system.py"
49 ];
50
51 disabledTests = [
52 # Some of the tests have build-system hardware-based impurities (like
53 # reading temperature sensor values). Disable them to avoid the failures
54 # that sometimes result.
55 "cpu_freq"
56 "cpu_times"
57 "disk_io_counters"
58 "sensors_battery"
59 "sensors_temperatures"
60 "user"
61 "test_disk_partitions" # problematic on Hydra's Linux builders, apparently
62 ];
63
64 pythonImportsCheck = [ "psutil" ];
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 = [ ];
72 };
73}