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