2024-04-21 15:54:59 +00:00
|
|
|
{ lib
|
|
|
|
, python3Packages
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, testers
|
|
|
|
, backblaze-b2
|
2024-01-25 14:12:00 +00:00
|
|
|
# executable is renamed to backblaze-b2 by default, to avoid collision with boost's 'b2'
|
|
|
|
, execName ? "backblaze-b2"
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
python3Packages.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "backblaze-b2";
|
2024-06-20 14:57:18 +00:00
|
|
|
version = "4.0.1";
|
2024-04-21 15:54:59 +00:00
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Backblaze";
|
|
|
|
repo = "B2_Command_Line_Tool";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-06-20 14:57:18 +00:00
|
|
|
hash = "sha256-rZUWPSI7CrKOdEKdsSpekwBerbIMf2iiVrWkV8WrqSc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = with python3Packages; [
|
2023-10-09 19:29:22 +00:00
|
|
|
installShellFiles
|
2024-06-05 15:53:02 +00:00
|
|
|
argcomplete
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
build-system = with python3Packages; [
|
|
|
|
pdm-backend
|
|
|
|
];
|
|
|
|
|
|
|
|
dependencies = with python3Packages; [
|
2023-10-09 19:29:22 +00:00
|
|
|
argcomplete
|
|
|
|
arrow
|
2020-10-07 09:15:18 +00:00
|
|
|
b2sdk
|
2020-11-30 08:33:03 +00:00
|
|
|
phx-class-registry
|
2021-05-20 23:08:51 +00:00
|
|
|
docutils
|
|
|
|
rst2ansi
|
2022-08-21 13:32:41 +00:00
|
|
|
tabulate
|
2023-10-09 19:29:22 +00:00
|
|
|
tqdm
|
2024-01-02 11:29:13 +00:00
|
|
|
platformdirs
|
|
|
|
packaging
|
|
|
|
setuptools
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = with python3Packages; [
|
2022-08-21 13:32:41 +00:00
|
|
|
backoff
|
2022-09-22 12:36:57 +00:00
|
|
|
more-itertools
|
2023-10-09 19:29:22 +00:00
|
|
|
pexpect
|
2021-10-28 06:52:43 +00:00
|
|
|
pytestCheckHook
|
2024-04-21 15:54:59 +00:00
|
|
|
pytest-xdist
|
2021-10-28 06:52:43 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
'';
|
|
|
|
|
|
|
|
disabledTestPaths = [
|
2024-04-21 15:54:59 +00:00
|
|
|
# Test requires network
|
2022-08-21 13:32:41 +00:00
|
|
|
"test/integration/test_b2_command_line.py"
|
2024-04-21 15:54:59 +00:00
|
|
|
"test/integration/test_tqdm_closer.py"
|
2023-10-09 19:29:22 +00:00
|
|
|
# it's hard to make it work on nix
|
|
|
|
"test/integration/test_autocomplete.py"
|
2024-04-21 15:54:59 +00:00
|
|
|
"test/unit/test_console_tool.py"
|
|
|
|
# this one causes successive tests to fail
|
|
|
|
"test/unit/_cli/test_autocomplete_cache.py"
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
# Autocomplete is not successful in a sandbox
|
|
|
|
"test_autocomplete_installer"
|
|
|
|
"test_help"
|
|
|
|
"test_install_autocomplete"
|
2020-11-30 08:33:03 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
postInstall = lib.optionalString (execName != "b2") ''
|
|
|
|
mv "$out/bin/b2" "$out/bin/${execName}"
|
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
installShellCompletion --cmd ${execName} \
|
2024-06-05 15:53:02 +00:00
|
|
|
--bash <(register-python-argcomplete ${execName}) \
|
|
|
|
--zsh <(register-python-argcomplete ${execName})
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
passthru.tests.version = (testers.testVersion {
|
|
|
|
package = backblaze-b2;
|
2024-01-25 14:12:00 +00:00
|
|
|
command = "${execName} version --short";
|
2024-01-02 11:29:13 +00:00
|
|
|
}).overrideAttrs (old: {
|
|
|
|
# workaround the error: Permission denied: '/homeless-shelter'
|
|
|
|
# backblaze-b2 fails to create a 'b2' directory under the XDG config path
|
2024-04-21 15:54:59 +00:00
|
|
|
preHook = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
'';
|
2024-01-02 11:29:13 +00:00
|
|
|
});
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Command-line tool for accessing the Backblaze B2 storage service";
|
|
|
|
homepage = "https://github.com/Backblaze/B2_Command_Line_Tool";
|
2023-10-09 19:29:22 +00:00
|
|
|
changelog = "https://github.com/Backblaze/B2_Command_Line_Tool/blob/v${version}/CHANGELOG.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2024-02-29 20:09:43 +00:00
|
|
|
maintainers = with maintainers; [ hrdinka tomhoule ];
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "backblaze-b2";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|