1{ stdenv, buildPythonPackage, fetchFromGitHub, pytest, nose, libarchive, glibcLocales 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 name = "${pname}-${version}"; 12 version = "3.0"; 13 14 src = fetchFromGitHub { 15 owner = "markokr"; 16 repo = "rarfile"; 17 rev = "rarfile_3_0"; 18 sha256 = "07yliz6p1bxzhipnrgz133gl8laic35gl4rqfay7f1vc384ch7sn"; 19 }; 20 buildInputs = [ pytest nose glibcLocales ]; 21 22 prePatch = '' 23 substituteInPlace rarfile.py \ 24 '' + (if useUnrar then 25 ''--replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\"" 26 '' 27 else 28 ''--replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\"" 29 '') 30 + '' 31 ''; 32 # the tests only work with the standard unrar package 33 doCheck = useUnrar; 34 LC_ALL = "en_US.UTF-8"; 35 checkPhase = '' 36 py.test test -k "not test_printdir" 37 ''; 38 39 meta = with stdenv.lib; { 40 description = "RAR archive reader for Python"; 41 homepage = https://github.com/markokr/rarfile; 42 license = licenses.isc; 43 }; 44}