about summary refs log tree commit diff
path: root/pkgs/development/tools/py-spy/default.nix
blob: 01d847649bbf86d4da341e566f1e7246b398af06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ 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 ];
  };
}