1{
2 lib,
3 aspectlib,
4 buildPythonPackage,
5 elasticsearch,
6 elastic-transport,
7 fetchFromGitHub,
8 fetchpatch,
9 freezegun,
10 git,
11 mercurial,
12 py-cpuinfo,
13 pygal,
14 pytest,
15 pytestCheckHook,
16 pytest-xdist,
17 pythonOlder,
18 setuptools,
19}:
20
21buildPythonPackage rec {
22 pname = "pytest-benchmark";
23 version = "4.0.0";
24 pyproject = true;
25
26 disabled = pythonOlder "3.7";
27
28 src = fetchFromGitHub {
29 owner = "ionelmc";
30 repo = pname;
31 rev = "v${version}";
32 hash = "sha256-f9Ty4+5PycraxoLUSa9JFusV5Cot6bBWKfOGHZIRR3o=";
33 };
34
35 patches = [
36 # replace distutils.spawn.find_executable with shutil.which
37 (fetchpatch {
38 url = "https://github.com/ionelmc/pytest-benchmark/commit/728752d2976ef53fde7e40beb3e55f09cf4d4736.patch";
39 hash = "sha256-WIQADCLey5Y79UJUj9J5E02HQ0O86xBh/3IeGLpVrWI=";
40 })
41 # fix tests with python3.11+; https://github.com/ionelmc/pytest-benchmark/pull/232
42 (fetchpatch {
43 url = "https://github.com/ionelmc/pytest-benchmark/commit/b2f624afd68a3090f20187a46284904dd4baa4f6.patch";
44 hash = "sha256-cylxPj/d0YzvOGw+ncVSCnQHwq2cukrgXhBHePPwjO0=";
45 })
46 (fetchpatch {
47 url = "https://github.com/ionelmc/pytest-benchmark/commit/2b987f5be1873617f02f24cb6d76196f9aed21bd.patch";
48 hash = "sha256-92kWEd935Co6uc/1y5OGKsc5/or81bORSdaiQFjDyTw=";
49 })
50 ];
51
52 nativeBuildInputs = [ setuptools ];
53
54 buildInputs = [ pytest ];
55
56 propagatedBuildInputs = [ py-cpuinfo ];
57
58 passthru.optional-dependencies = {
59 aspect = [ aspectlib ];
60 histogram = [ pygal ];
61 elasticsearch = [ elasticsearch ];
62 };
63
64 pythonImportsCheck = [ "pytest_benchmark" ];
65
66 nativeCheckInputs = [
67 elastic-transport
68 freezegun
69 git
70 mercurial
71 pytestCheckHook
72 pytest-xdist
73 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
74
75 pytestFlagsArray = [
76 "-W"
77 "ignore::DeprecationWarning"
78 ];
79
80 preCheck = ''
81 export PATH="$out/bin:$PATH"
82 '';
83
84 disabledTests = lib.optionals (pythonOlder "3.12") [
85 # AttributeError: 'PluginImportFixer' object has no attribute 'find_spec'
86 "test_compare_1"
87 "test_compare_2"
88 "test_regression_checks"
89 "test_regression_checks_inf"
90 "test_rendering"
91 ];
92
93 meta = with lib; {
94 changelog = "https://github.com/ionelmc/pytest-benchmark/blob/${src.rev}/CHANGELOG.rst";
95 description = "Pytest fixture for benchmarking code";
96 homepage = "https://github.com/ionelmc/pytest-benchmark";
97 license = licenses.bsd2;
98 maintainers = with maintainers; [ dotlambda ];
99 };
100}