nixpkgs/pkgs/development/python-modules/psutil/default.nix
Peder Bergebakken Sundt 5aba99242e treewide: fix typos in comments
Made with

```shell
git restore .
fd '\.nix$' pkgs/ --type f -j1 -x bash -xc "$(cat <<"EOF"
    typos --no-check-filenames --write-changes "$1"
    git diff --exit-code "$1" && exit
    #( git diff "$1" | grep -qE "^\+ +[^# ]") && git restore "$1"
    count1="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> ' | wc -l )"
    count2="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> (<span style="color:#f8f8f2;"> *</span>)?<span style="color:#75715e;">.*</span>$' | wc -l )"
    [[ $count1 -ne $count2 ]] && git restore "$1"
EOF
)" -- {}
```

and filtered with `GIT_DIFF_OPTS='--unified=15' git -c interactive.singleKey=true add --patch`

I initially tried using the tree-sitter cli, python bindings and even ast-grep through various means, but this is what I ended up with.
2025-02-24 10:44:41 +01:00

80 lines
2.3 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
CoreFoundation,
fetchPypi,
setuptools,
IOKit,
pytestCheckHook,
python,
pythonOlder,
}:
buildPythonPackage rec {
pname = "psutil";
version = "6.1.1";
pyproject = true;
inherit stdenv;
disabled = pythonOlder "3.7";
src = fetchPypi {
inherit pname version;
hash = "sha256-z4SWcowY8tC0UZjwaJW+UvNmEXEXRrfzDEZLQitQ4vU=";
};
postPatch = ''
# stick to the old SDK name for now
# https://developer.apple.com/documentation/iokit/kiomasterportdefault/
# https://developer.apple.com/documentation/iokit/kiomainportdefault/
substituteInPlace psutil/arch/osx/cpu.c \
--replace-fail kIOMainPortDefault kIOMasterPortDefault
'';
build-system = [ setuptools ];
buildInputs =
# workaround for https://github.com/NixOS/nixpkgs/issues/146760
lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ CoreFoundation ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ IOKit ];
nativeCheckInputs = [ pytestCheckHook ];
# Segfaults on darwin:
# https://github.com/giampaolo/psutil/issues/1715
doCheck = !stdenv.hostPlatform.isDarwin;
# In addition to the issues listed above there are some that occure due to
# our sandboxing which we can work around by disabling some tests:
# - cpu_times was flaky on darwin
# - the other disabled tests are likely due to sandboxing (missing specific errors)
pytestFlagsArray = [
# Note: $out must be referenced as test import paths are relative
"${placeholder "out"}/${python.sitePackages}/psutil/tests/test_system.py"
];
disabledTests = [
# Some of the tests have build-system hardware-based impurities (like
# reading temperature sensor values). Disable them to avoid the failures
# that sometimes result.
"cpu_freq"
"cpu_times"
"disk_io_counters"
"sensors_battery"
"sensors_temperatures"
"user"
"test_disk_partitions" # problematic on Hydra's Linux builders, apparently
];
pythonImportsCheck = [ "psutil" ];
meta = with lib; {
description = "Process and system utilization information interface";
homepage = "https://github.com/giampaolo/psutil";
changelog = "https://github.com/giampaolo/psutil/blob/release-${version}/HISTORY.rst";
license = licenses.bsd3;
maintainers = [ ];
};
}