Skip to content

Commit

Permalink
python3Packages.locust: init at 2.31.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jokatzke committed Nov 19, 2024
1 parent 87e1d49 commit be67987
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
105 changes: 105 additions & 0 deletions pkgs/development/python-modules/locust/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
32 changes: 32 additions & 0 deletions pkgs/development/python-modules/locust/webui.nix
Original file line number Diff line number Diff line change
@@ -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
'';
})
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down

0 comments on commit be67987

Please sign in to comment.