2020-10-06 09:22:51 +01:00
|
|
|
{ stdenv, buildPythonPackage, fetchFromGitHub, pytestCheckHook, nose, libarchive, glibcLocales, isPy27
|
2017-05-31 04:53:29 +01:00
|
|
|
# unrar is non-free software
|
|
|
|
, useUnrar ? false, unrar
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert useUnrar -> unrar != null;
|
|
|
|
assert !useUnrar -> libarchive != null;
|
2017-05-20 08:19:40 +01:00
|
|
|
|
2020-10-06 09:22:51 +01:00
|
|
|
buildPythonPackage rec {
|
2017-05-27 10:25:35 +01:00
|
|
|
pname = "rarfile";
|
2020-10-06 09:22:51 +01:00
|
|
|
version = "4.0";
|
|
|
|
disabled = isPy27;
|
2017-05-20 08:19:40 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "markokr";
|
|
|
|
repo = "rarfile";
|
2020-10-06 09:22:51 +01:00
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0gpriqkvcb6bsccvq8b099xjv5fkjs0d7g4636d5jphy417jxk5m";
|
2017-05-20 08:19:40 +01:00
|
|
|
};
|
2020-10-06 09:22:51 +01:00
|
|
|
|
|
|
|
checkInputs = [ pytestCheckHook nose glibcLocales ];
|
2017-05-20 08:19:40 +01:00
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
substituteInPlace rarfile.py \
|
2017-05-31 04:53:29 +01:00
|
|
|
'' + (if useUnrar then
|
|
|
|
''--replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\""
|
|
|
|
''
|
|
|
|
else
|
|
|
|
''--replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\""
|
|
|
|
'')
|
|
|
|
+ ''
|
|
|
|
'';
|
|
|
|
# the tests only work with the standard unrar package
|
|
|
|
doCheck = useUnrar;
|
2017-05-20 08:19:40 +01:00
|
|
|
LC_ALL = "en_US.UTF-8";
|
2020-10-06 09:22:51 +01:00
|
|
|
pythonImportsCheck = [ "rarfile" ];
|
2017-05-20 08:19:40 +01:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "RAR archive reader for Python";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/markokr/rarfile";
|
2017-05-20 08:19:40 +01:00
|
|
|
license = licenses.isc;
|
|
|
|
};
|
|
|
|
}
|