1{ lib, buildPythonPackage, fetchFromGitHub, pytestCheckHook, nose, libarchive, glibcLocales, isPy27 2# unrar is non-free software 3, useUnrar ? false, unrar 4}: 5 6assert useUnrar -> unrar != null; 7assert !useUnrar -> libarchive != null; 8 9buildPythonPackage rec { 10 pname = "rarfile"; 11 version = "4.1"; 12 disabled = isPy27; 13 14 src = fetchFromGitHub { 15 owner = "markokr"; 16 repo = "rarfile"; 17 rev = "v${version}"; 18 sha256 = "sha256-9PT4/KgkdFhTjZIia2xiSM5VnaZ4040Ww7bG9Nr3XDU="; 19 }; 20 21 nativeCheckInputs = [ pytestCheckHook nose glibcLocales ]; 22 23 prePatch = '' 24 substituteInPlace rarfile.py \ 25 '' + (if useUnrar then 26 ''--replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\"" 27 '' 28 else 29 ''--replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\"" 30 '') 31 + ""; 32 # the tests only work with the standard unrar package 33 doCheck = useUnrar; 34 LC_ALL = "en_US.UTF-8"; 35 pythonImportsCheck = [ "rarfile" ]; 36 37 meta = with lib; { 38 description = "RAR archive reader for Python"; 39 homepage = "https://github.com/markokr/rarfile"; 40 license = licenses.isc; 41 }; 42}