1{ lib, stdenv, buildPythonPackage, fetchPypi, isPy27, python
2, darwin
3, pytest
4, mock
5, ipaddress
6, unittest2
7}:
8
9buildPythonPackage rec {
10 pname = "psutil";
11 version = "5.7.2";
12
13 src = fetchPypi {
14 inherit pname version;
15 sha256 = "90990af1c3c67195c44c9a889184f84f5b2320dce3ee3acbd054e3ba0b4a7beb";
16 };
17
18 # arch doesn't report frequency is the same way
19 # tests segfaults on darwin https://github.com/giampaolo/psutil/issues/1715
20 doCheck = !stdenv.isDarwin && stdenv.isx86_64;
21 checkInputs = [ pytest ]
22 ++ lib.optionals isPy27 [ mock ipaddress unittest2 ];
23 # out must be referenced as test import paths are relative
24 # disable tests which don't work in sandbox
25 # cpu_times is flakey on darwin
26 checkPhase = ''
27 pytest $out/${python.sitePackages}/psutil/tests/test_system.py \
28 -k 'not user and not disk_io_counters and not sensors_battery and not cpu_times'
29 '';
30
31 buildInputs = lib.optionals stdenv.isDarwin [ darwin.IOKit ];
32
33 pythonImportsCheck = [ "psutil" ];
34
35 meta = with lib; {
36 description = "Process and system utilization information interface for python";
37 homepage = "https://github.com/giampaolo/psutil";
38 license = licenses.bsd3;
39 maintainers = with maintainers; [ jonringer ];
40 };
41}