depot/third_party/nixpkgs/pkgs/development/python-modules/rarfile/default.nix
Default email 5ca88bfbb9 Project import generated by Copybara.
GitOrigin-RevId: 9f918d616c5321ad374ae6cb5ea89c9e04bf3e58
2024-07-31 10:19:44 +00:00

63 lines
1.3 KiB
Nix

{
lib,
buildPythonPackage,
fetchFromGitHub,
pytestCheckHook,
libarchive,
pythonOlder,
setuptools,
# unrar is non-free software
useUnrar ? false,
unrar,
}:
assert useUnrar -> unrar != null;
assert !useUnrar -> libarchive != null;
buildPythonPackage rec {
pname = "rarfile";
version = "4.2";
pyproject = true;
disabled = pythonOlder "3.6";
src = fetchFromGitHub {
owner = "markokr";
repo = "rarfile";
rev = "refs/tags/v${version}";
hash = "sha256-ZiwD2LG25fMd4Z+QWsh/x3ceG5QRBH4s/TZDwMnfpNI=";
};
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\""
''
)
+ "";
build-system = [ setuptools ];
nativeCheckInputs = [ pytestCheckHook ];
# The tests only work with the standard unrar package
doCheck = useUnrar;
pythonImportsCheck = [ "rarfile" ];
meta = with lib; {
description = "RAR archive reader for Python";
homepage = "https://github.com/markokr/rarfile";
changelog = "https://github.com/markokr/rarfile/releases/tag/v${version}";
license = licenses.isc;
maintainers = [ ];
};
}