1{ lib, buildPythonApplication, fetchFromGitHub
2, arrow, futures, logfury, requests, six, tqdm
3}:
4
5buildPythonApplication rec {
6 pname = "backblaze-b2";
7 version = "1.3.6";
8
9 src = fetchFromGitHub {
10 owner = "Backblaze";
11 repo = "B2_Command_Line_Tool";
12 rev = "v${version}";
13 sha256 = "12axb0c56razfhrx1l62sjvdrbg6vz0yyqph2mxyjza1ywpb93b5";
14 };
15
16 propagatedBuildInputs = [ arrow futures logfury requests six tqdm ];
17
18 checkPhase = ''
19 python test_b2_command_line.py test
20 '';
21
22 postPatch = ''
23 # b2 uses an upper bound on arrow, because arrow 0.12.1 is not
24 # compatible with Python 2.6:
25 #
26 # https://github.com/crsmithdev/arrow/issues/517
27 #
28 # However, since we use Python 2.7, newer versions of arrow are fine.
29
30 sed -i 's/,<0.12.1//g' requirements.txt
31 '';
32
33 postInstall = ''
34 mv "$out/bin/b2" "$out/bin/backblaze-b2"
35
36 sed 's/^have b2 \&\&$/_have backblaze-b2 \&\&/' -i contrib/bash_completion/b2
37 sed 's/^\(complete -F _b2\) b2/\1 backblaze-b2/' -i contrib/bash_completion/b2
38
39 mkdir -p "$out/etc/bash_completion.d"
40 cp contrib/bash_completion/b2 "$out/etc/bash_completion.d/backblaze-b2"
41 '';
42
43 meta = with lib; {
44 description = "Command-line tool for accessing the Backblaze B2 storage service";
45 homepage = https://github.com/Backblaze/B2_Command_Line_Tool;
46 license = licenses.mit;
47 maintainers = with maintainers; [ hrdinka kevincox ];
48 platforms = platforms.unix;
49 };
50}