2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2021-03-09 03:18:52 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
2022-11-21 17:40:18 +00:00
|
|
|
, fetchFromGitHub
|
2021-03-09 03:18:52 +00:00
|
|
|
, pytestCheckHook
|
2022-11-21 17:40:18 +00:00
|
|
|
, pythonOlder
|
2021-03-09 03:18:52 +00:00
|
|
|
, sysctl
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "py-cpuinfo";
|
2022-11-21 17:40:18 +00:00
|
|
|
version = "9.0.0";
|
|
|
|
format = "setuptools";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "workhorsy";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-11-21 17:40:18 +00:00
|
|
|
hash = "sha256-Q5u0guAqDVhf6bvJTzNvCpWbIzjxxAjE7s0OuXj9T4Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
checkInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
# On Darwin sysctl is used to read CPU information.
|
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
|
|
|
substituteInPlace cpuinfo/cpuinfo.py \
|
|
|
|
--replace "len(_program_paths('sysctl')) > 0" "True" \
|
|
|
|
--replace "_run_and_get_stdout(['sysctl'" "_run_and_get_stdout(['${sysctl}/bin/sysctl'"
|
|
|
|
'';
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"cpuinfo"
|
|
|
|
];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Get CPU info with pure Python";
|
2020-04-24 23:36:52 +00:00
|
|
|
longDescription = ''
|
|
|
|
Py-cpuinfo gets CPU info with pure Python and should work without any
|
|
|
|
extra programs or libraries, beyond what your OS provides. It does not
|
|
|
|
require any compilation (C/C++, assembly, etc.) to use and works with
|
2021-05-20 23:08:51 +00:00
|
|
|
Python.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-05-20 23:08:51 +00:00
|
|
|
homepage = "https://github.com/workhorsy/py-cpuinfo";
|
2020-04-24 23:36:52 +00:00
|
|
|
changelog = "https://github.com/workhorsy/py-cpuinfo/blob/v${version}/ChangeLog";
|
2021-05-20 23:08:51 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ costrouc ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|