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