1{ lib
2, stdenv
3, fetchFromGitHub
4, buildPythonPackage
5, pytestCheckHook
6, sysctl
7}:
8
9buildPythonPackage rec {
10 pname = "py-cpuinfo";
11 version = "8.0.0";
12
13 src = fetchFromGitHub {
14 owner = "workhorsy";
15 repo = pname;
16 rev = "v${version}";
17 sha256 = "sha256-Mgzj1HTasUNHeHMVwV6d+TeyVqnBNUwCJ1EC3kfovf8=";
18 };
19
20 checkInputs = [
21 pytestCheckHook
22 ];
23
24 # On Darwin sysctl is used to read CPU information.
25 postPatch = lib.optionalString stdenv.isDarwin ''
26 substituteInPlace cpuinfo/cpuinfo.py \
27 --replace "len(_program_paths('sysctl')) > 0" "True" \
28 --replace "_run_and_get_stdout(['sysctl'" "_run_and_get_stdout(['${sysctl}/bin/sysctl'"
29 '';
30
31 pythonImportsCheck = [ "cpuinfo" ];
32
33 meta = with lib; {
34 description = "Get CPU info with pure Python";
35 longDescription = ''
36 Py-cpuinfo gets CPU info with pure Python and should work without any
37 extra programs or libraries, beyond what your OS provides. It does not
38 require any compilation (C/C++, assembly, etc.) to use and works with
39 Python.
40 '';
41 homepage = "https://github.com/workhorsy/py-cpuinfo";
42 changelog = "https://github.com/workhorsy/py-cpuinfo/blob/v${version}/ChangeLog";
43 license = licenses.mit;
44 maintainers = with maintainers; [ costrouc ];
45 };
46}