1{
2 lib,
3 buildPythonPackage,
4 python,
5 callPackage,
6 fetchFromGitHub,
7 hatchling,
8 hatch-vcs,
9 pytestCheckHook,
10 configargparse,
11 cryptography,
12 flask,
13 flask-cors,
14 flask-login,
15 gevent,
16 geventhttpclient,
17 msgpack,
18 psutil,
19 pyquery,
20 pyzmq,
21 requests,
22 retry,
23 tomli,
24 werkzeug,
25}:
26
27buildPythonPackage rec {
28 pname = "locust";
29 version = "2.33.1";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "locustio";
34 repo = "locust";
35 tag = version;
36 hash = "sha256-cOYdf3F1OF1P4xFEG3isuiePIl1tHnjL7UVoFIpb40A=";
37 };
38
39 postPatch = ''
40 substituteInPlace locust/test/test_main.py \
41 --replace-fail '"locust"' '"${placeholder "out"}/bin/locust"'
42
43 substituteInPlace locust/test/test_log.py \
44 --replace-fail '"locust"' '"${placeholder "out"}/bin/locust"'
45 '';
46
47 webui = callPackage ./webui.nix {
48 inherit version;
49 src = "${src}/locust/webui";
50 };
51
52 build-system = [
53 hatchling
54 hatch-vcs
55 ];
56
57 pythonRelaxDeps = [
58 # version 0.7.0.dev0 is not considered to be >= 0.6.3
59 "flask-login"
60 ];
61
62 dependencies = [
63 configargparse
64 flask
65 flask-cors
66 flask-login
67 gevent
68 geventhttpclient
69 msgpack
70 psutil
71 pyzmq
72 requests
73 tomli
74 werkzeug
75 ];
76
77 pythonImportsCheck = [ "locust" ];
78
79 nativeCheckInputs = [
80 cryptography
81 pyquery
82 pytestCheckHook
83 retry
84 ];
85
86 # locust's test suite is very flaky, due to heavy reliance on timing-based tests and access to the
87 # network.
88 doCheck = false;
89
90 meta = {
91 description = "Developer-friendly load testing framework";
92 homepage = "https://docs.locust.io/";
93 changelog = "https://github.com/locustio/locust/blob/${src.tag}/CHANGELOG.md";
94 license = lib.licenses.mit;
95 maintainers = with lib.maintainers; [ jokatzke ];
96 };
97}