Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonAtLeast,
7
8 # build-system
9 pkg-config,
10 rustc,
11 rustPlatform,
12
13 # tests
14 numpy,
15 pytestCheckHook,
16 pytest-benchmark,
17 pytest-rerunfailures,
18}:
19
20buildPythonPackage rec {
21 pname = "gilknocker";
22 version = "0.4.2-post3";
23 pyproject = true;
24
25 src = fetchFromGitHub {
26 owner = "milesgranger";
27 repo = "gilknocker";
28 tag = "v${version}";
29 hash = "sha256-GSybOILOP0lwxUPB9a8whQvEPS7OdeHcm0pxky7gwkg=";
30 };
31
32 cargoDeps = rustPlatform.fetchCargoVendor {
33 inherit pname version src;
34 hash = "sha256-C3rxqmZMSc6SC8bU5VB61x8Xk/crD3o7Nr1xvzv7uqI=";
35 };
36
37 nativeBuildInputs =
38 with rustPlatform;
39 [
40 cargoSetupHook
41 maturinBuildHook
42 ]
43 ++ [
44 pkg-config
45 rustc
46 ];
47
48 pythonImportsCheck = [
49 "gilknocker"
50 ];
51
52 nativeCheckInputs = [
53 numpy
54 pytestCheckHook
55 pytest-benchmark
56 pytest-rerunfailures
57 ];
58
59 enabledTestPaths = [
60 # skip the benchmarks as they can segfault
61 # https://github.com/milesgranger/gilknocker/issues/35
62 "tests"
63 ];
64
65 disabledTestPaths = lib.optionals (pythonAtLeast "3.14") [
66 # segfaults
67 # https://github.com/milesgranger/gilknocker/issues/35
68 "benchmarks"
69 ];
70
71 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
72 # depends on an empirically-derived threshold that fails on fast and slow machines.
73 # https://github.com/milesgranger/gilknocker/issues/36
74 "test_knockknock_some_gil"
75 ];
76
77 pytestFlags = [ "--benchmark-disable" ];
78
79 meta = {
80 description = "Knock on the Python GIL, determine how busy it is";
81 homepage = "https://github.com/milesgranger/gilknocker";
82 changelog = "https://github.com/milesgranger/gilknocker/releases/tag/v${version}";
83 license = with lib.licenses; [
84 mit
85 unlicense
86 ];
87 maintainers = with lib.maintainers; [ daspk04 ];
88 };
89}