lol
1{ lib
2, stdenv
3, darwin
4, fetchFromGitHub
5, libunwind
6, python3
7, rustPlatform
8}:
9
10rustPlatform.buildRustPackage rec {
11 pname = "py-spy";
12 version = "0.3.14";
13
14 src = fetchFromGitHub {
15 owner = "benfred";
16 repo = "py-spy";
17 rev = "refs/tags/v${version}";
18 hash = "sha256-NciyzKiDKIMeuHhTjzmHIc3dYW4AniuCNjZugm4hMss=";
19 };
20
21 cargoHash = "sha256-nm+44YWSJOOg9a9d8b3APXW50ThV3iA2C/QsJMttscE=";
22
23 # error: linker `arm-linux-gnueabihf-gcc` not found
24 postPatch = ''
25 rm .cargo/config
26 '';
27
28 nativeBuildInputs = [
29 rustPlatform.bindgenHook
30 ];
31
32 nativeCheckInputs = [
33 python3
34 ];
35
36 buildInputs = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
37 # Pull a header that contains a definition of proc_pid_rusage().
38 darwin.apple_sdk_11_0.Libsystem
39 ];
40
41 env.NIX_CFLAGS_COMPILE = "-L${libunwind}/lib";
42
43 checkFlags = [
44 # thread 'python_data_access::tests::test_copy_string' panicked at 'called `Result::unwrap()` on an `Err`
45 "--skip=python_data_access::tests::test_copy_string"
46 ] ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [
47 # panicked at 'called `Result::unwrap()` on an `Err` value: failed to get os threadid
48 "--skip=test_thread_reuse"
49 ];
50
51 meta = with lib; {
52 description = "Sampling profiler for Python programs";
53 homepage = "https://github.com/benfred/py-spy";
54 changelog = "https://github.com/benfred/py-spy/releases/tag/v${version}";
55 license = licenses.mit;
56 maintainers = with maintainers; [ lnl7 ];
57 };
58}