2021-02-05 17:12:51 +00:00
|
|
|
{ lib, buildPythonPackage, fetchFromGitHub, pytestCheckHook, nose, libarchive, glibcLocales, isPy27
|
2020-04-24 23:36:52 +00:00
|
|
|
# unrar is non-free software
|
|
|
|
, useUnrar ? false, unrar
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert useUnrar -> unrar != null;
|
|
|
|
assert !useUnrar -> libarchive != null;
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
buildPythonPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "rarfile";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "4.1";
|
2020-10-07 09:15:18 +00:00
|
|
|
disabled = isPy27;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "markokr";
|
|
|
|
repo = "rarfile";
|
2020-10-07 09:15:18 +00:00
|
|
|
rev = "v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
sha256 = "sha256-9PT4/KgkdFhTjZIia2xiSM5VnaZ4040Ww7bG9Nr3XDU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook nose glibcLocales ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
substituteInPlace rarfile.py \
|
|
|
|
'' + (if useUnrar then
|
|
|
|
''--replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\""
|
|
|
|
''
|
|
|
|
else
|
|
|
|
''--replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\""
|
|
|
|
'')
|
2021-02-05 17:12:51 +00:00
|
|
|
+ "";
|
2020-04-24 23:36:52 +00:00
|
|
|
# the tests only work with the standard unrar package
|
|
|
|
doCheck = useUnrar;
|
|
|
|
LC_ALL = "en_US.UTF-8";
|
2020-10-07 09:15:18 +00:00
|
|
|
pythonImportsCheck = [ "rarfile" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "RAR archive reader for Python";
|
|
|
|
homepage = "https://github.com/markokr/rarfile";
|
|
|
|
license = licenses.isc;
|
|
|
|
};
|
|
|
|
}
|