2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
pytestCheckHook,
|
|
|
|
libarchive,
|
|
|
|
pythonOlder,
|
|
|
|
setuptools,
|
|
|
|
# unrar is non-free software
|
|
|
|
useUnrar ? false,
|
|
|
|
unrar,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
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";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "4.2";
|
2024-05-15 15:35:15 +00:00
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "markokr";
|
|
|
|
repo = "rarfile";
|
2024-04-21 15:54:59 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-ZiwD2LG25fMd4Z+QWsh/x3ceG5QRBH4s/TZDwMnfpNI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2024-05-15 15:35:15 +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\""
|
2020-04-24 23:36:52 +00:00
|
|
|
''
|
2024-05-15 15:35:15 +00:00
|
|
|
)
|
|
|
|
+ "";
|
|
|
|
|
|
|
|
build-system = [ setuptools ];
|
|
|
|
|
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
|
|
|
|
|
|
|
# The tests only work with the standard unrar package
|
2020-04-24 23:36:52 +00:00
|
|
|
doCheck = useUnrar;
|
2024-05-15 15:35:15 +00:00
|
|
|
|
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";
|
2024-05-15 15:35:15 +00:00
|
|
|
changelog = "https://github.com/markokr/rarfile/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.isc;
|
2024-05-15 15:35:15 +00:00
|
|
|
maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|