1{
2 lib,
3 buildPythonPackage,
4 cffi,
5 fetchFromGitHub,
6 filelock,
7 hatchling,
8 importlib-metadata,
9 pytest-benchmark,
10 pytest-cov-stub,
11 pytest-xdist,
12 pytest,
13 pytestCheckHook,
14 rich,
15 semver,
16 setuptools,
17}:
18
19let
20 instrument-hooks = fetchFromGitHub {
21 owner = "CodSpeedHQ";
22 repo = "instrument-hooks";
23 rev = "b003e5024d61cfb784d6ac6f3ffd7d61bf7b9ec9";
24 hash = "sha256-JTSH4wOpOGJ97iV6sagiRUu8d3sKM2NJRXcB3NmozNQ=";
25 };
26in
27
28buildPythonPackage rec {
29 pname = "pytest-codspeed";
30 version = "4.0.0";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "CodSpeedHQ";
35 repo = "pytest-codspeed";
36 tag = "v${version}";
37 hash = "sha256-5fdG7AEiLD3ZZzU/7zBK0+LDacTZooyDUo+FefcE4uQ=";
38 };
39
40 postPatch = ''
41 pushd src/pytest_codspeed/instruments/hooks
42 rmdir instrument-hooks
43 ln -nsf ${instrument-hooks} instrument-hooks
44 popd
45 '';
46
47 build-system = [ hatchling ];
48
49 buildInputs = [ pytest ];
50
51 dependencies = [
52 cffi
53 filelock
54 importlib-metadata
55 rich
56 setuptools
57 ];
58
59 optional-dependencies = {
60 compat = [
61 pytest-benchmark
62 pytest-xdist
63 ];
64 };
65
66 nativeCheckInputs = [
67 semver
68 pytest-cov-stub
69 pytestCheckHook
70 ];
71
72 pythonImportsCheck = [ "pytest_codspeed" ];
73
74 meta = {
75 description = "Pytest plugin to create CodSpeed benchmarks";
76 homepage = "https://github.com/CodSpeedHQ/pytest-codspeed";
77 changelog = "https://github.com/CodSpeedHQ/pytest-codspeed/releases/tag/${src.tag}";
78 license = lib.licenses.mit;
79 maintainers = with lib.maintainers; [ fab ];
80 };
81}