nixpkgs/pkgs/development/tools/py-spy/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

60 lines
1.6 KiB
Nix

{ lib
, stdenv
, darwin
, fetchFromGitHub
, libunwind
, python3
, rustPlatform
}:
rustPlatform.buildRustPackage rec {
pname = "py-spy";
version = "0.3.14-unstable-2024-02-27";
src = fetchFromGitHub {
owner = "benfred";
repo = "py-spy";
rev = "8dd54929106916a3c961cc57c1172793ce126180";
hash = "sha256-rrngOqlXIJXbh3A7OBEcgoakZyyuvlHHXhWo3/1BRpY=";
};
cargoHash = "sha256-gNnuuq2cz168Gaw+gL2nJ8EC32BMPu9DgnRzIh1hGKk=";
# error: linker `arm-linux-gnueabihf-gcc` not found
postPatch = ''
rm .cargo/config
'';
nativeBuildInputs = [
rustPlatform.bindgenHook
];
nativeCheckInputs = [
python3
];
buildInputs = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
# Pull a header that contains a definition of proc_pid_rusage().
darwin.apple_sdk_11_0.Libsystem
];
env.NIX_CFLAGS_COMPILE = "-L${libunwind}/lib";
checkFlags = [
# thread 'python_data_access::tests::test_copy_string' panicked at 'called `Result::unwrap()` on an `Err`
"--skip=python_data_access::tests::test_copy_string"
] ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [
# panicked at 'called `Result::unwrap()` on an `Err` value: failed to get os threadid
"--skip=test_thread_reuse"
];
meta = with lib; {
description = "Sampling profiler for Python programs";
mainProgram = "py-spy";
homepage = "https://github.com/benfred/py-spy";
changelog = "https://github.com/benfred/py-spy/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [ lnl7 ];
};
}