diff --git a/pkgs/development/python-modules/locust/default.nix b/pkgs/development/python-modules/locust/default.nix new file mode 100644 index 0000000000000..ba7a193318e9f --- /dev/null +++ b/pkgs/development/python-modules/locust/default.nix @@ -0,0 +1,105 @@ +{ + lib, + buildPythonPackage, + python, + callPackage, + fetchFromGitHub, + poetry-core, + poetry-dynamic-versioning, + pytestCheckHook, + configargparse, + cryptography, + flask, + flask-cors, + flask-login, + gevent, + geventhttpclient, + msgpack, + psutil, + pyquery, + pyzmq, + requests, + retry, + tomli, + werkzeug, +}: + +buildPythonPackage rec { + pname = "locust"; + version = "2.31.2"; + pyproject = true; + + src = fetchFromGitHub { + owner = "locustio"; + repo = "locust"; + rev = "refs/tags/${version}"; + hash = "sha256-xDquVQjkWVER9h0a6DHWRZH6KtRf0jsThycSojDEdh4="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail 'script = "pre_build.py"' "" + + substituteInPlace locust/test/test_main.py \ + --replace-fail '"locust"' '"${placeholder "out"}/bin/locust"' + + substituteInPlace locust/test/test_log.py \ + --replace-fail '"locust"' '"${placeholder "out"}/bin/locust"' + ''; + + webui = callPackage ./webui.nix { + inherit version; + src = "${src}/locust/webui"; + }; + + preBuild = '' + mkdir -p $out/${python.sitePackages}/${pname} + ln -sf ${webui} $out/${python.sitePackages}/${pname}/webui + ''; + + build-system = [ + poetry-core + poetry-dynamic-versioning + ]; + + pythonRelaxDeps = [ + # version 0.7.0.dev0 is not considered to be >= 0.6.3 + "flask-login" + ]; + + dependencies = [ + configargparse + flask + flask-cors + flask-login + gevent + geventhttpclient + msgpack + psutil + pyzmq + requests + tomli + werkzeug + ]; + + pythonImportsCheck = [ "locust" ]; + + nativeCheckInputs = [ + cryptography + pyquery + pytestCheckHook + retry + ]; + + # locust's test suite is very flaky, due to heavy reliance on timing-based tests and access to the + # network. + doCheck = false; + + meta = { + description = "Developer-friendly load testing framework"; + homepage = "https://docs.locust.io/"; + changelog = "https://github.com/locustio/locust/blob/${version}/CHANGELOG.md"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ jokatzke ]; + }; +} diff --git a/pkgs/development/python-modules/locust/webui.nix b/pkgs/development/python-modules/locust/webui.nix new file mode 100644 index 0000000000000..c0a2a4f772c32 --- /dev/null +++ b/pkgs/development/python-modules/locust/webui.nix @@ -0,0 +1,32 @@ +{ + stdenv, + fetchYarnDeps, + yarnConfigHook, + yarnBuildHook, + nodejs, + version, + src, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "locust-ui"; + inherit version src; + + yarnOfflineCache = fetchYarnDeps { + yarnLock = "${finalAttrs.src}/yarn.lock"; + hash = "sha256-ek02mjB8DsBUOR28WSuqj6oVvxTq8EKTNXWFFI3OhuU="; + }; + + nativeBuildInputs = [ + yarnConfigHook + yarnBuildHook + nodejs + ]; + + dontNpmPrune = true; + yarnBuildScript = "build"; + postInstall = '' + mkdir -p $out/dist + cp -r dist/** $out/dist + ''; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 62f9ae46754db..13a6a1536fb05 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7550,6 +7550,8 @@ self: super: with self; { lockfile = callPackage ../development/python-modules/lockfile { }; + locust = callPackage ../development/python-modules/locust { }; + log-symbols = callPackage ../development/python-modules/log-symbols { }; logbook = callPackage ../development/python-modules/logbook { };