1{
2 argcomplete,
3 lib,
4 stdenv,
5 buildPythonPackage,
6 fetchFromGitHub,
7 installShellFiles,
8 pytestCheckHook,
9 p7zip,
10 cabextract,
11 zip,
12 lzip,
13 zpaq,
14 gnutar,
15 unar, # Free alternative to unrar
16 gnugrep,
17 diffutils,
18 file,
19 gzip,
20 bzip2,
21 xz,
22}:
23
24let
25 compression-utilities = [
26 p7zip
27 gnutar
28 unar
29 cabextract
30 zip
31 lzip
32 zpaq
33 gzip
34 gnugrep
35 diffutils
36 bzip2
37 file
38 xz
39 ];
40in
41buildPythonPackage rec {
42 pname = "patool";
43 version = "3.1.0";
44 format = "setuptools";
45
46 #pypi doesn't have test data
47 src = fetchFromGitHub {
48 owner = "wummel";
49 repo = pname;
50 tag = version;
51 hash = "sha256-mt/GUIRJHB2/Rritc+uNkolZzguYy2G/NKnSKNxKsLk=";
52 };
53
54 patches = [
55 # https://github.com/wummel/patool/pull/173
56 ./fix-rar-detection.patch
57 ];
58
59 postPatch = ''
60 substituteInPlace patoolib/util.py \
61 --replace "path = None" 'path = os.environ["PATH"] + ":${lib.makeBinPath compression-utilities}"'
62 '';
63
64 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
65 installShellCompletion --cmd patool \
66 --bash <(${argcomplete}/bin/register-python-argcomplete -s bash $out/bin/patool) \
67 --fish <(${argcomplete}/bin/register-python-argcomplete -s fish $out/bin/patool) \
68 --zsh <(${argcomplete}/bin/register-python-argcomplete -s zsh $out/bin/patool)
69 '';
70
71 nativeBuildInputs = [
72 installShellFiles
73 ];
74
75 nativeCheckInputs = [ pytestCheckHook ] ++ compression-utilities;
76
77 disabledTests = [
78 "test_unzip"
79 "test_unzip_file"
80 "test_zip"
81 "test_zip_file"
82 "test_7z"
83 "test_7z_file"
84 "test_7za_file"
85 "test_p7azip"
86 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ "test_ar" ];
87
88 meta = with lib; {
89 description = "portable archive file manager";
90 mainProgram = "patool";
91 homepage = "https://wummel.github.io/patool/";
92 license = licenses.gpl3;
93 maintainers = with maintainers; [ marius851000 ];
94 };
95}