Merge pull request #311377 from fabaff/rarfile-bump

python312Packages.rarfile: refactor
This commit is contained in:
Fabian Affolter
2024-05-13 20:41:05 +02:00
committed by GitHub

View File

@@ -1,6 +1,14 @@
{ lib, buildPythonPackage, fetchFromGitHub, pytestCheckHook, nose, libarchive, glibcLocales, isPy27 {
# unrar is non-free software lib,
, useUnrar ? false, unrar buildPythonPackage,
fetchFromGitHub,
pytestCheckHook,
libarchive,
pythonOlder,
setuptools,
# unrar is non-free software
useUnrar ? false,
unrar,
}: }:
assert useUnrar -> unrar != null; assert useUnrar -> unrar != null;
@@ -9,35 +17,47 @@ assert !useUnrar -> libarchive != null;
buildPythonPackage rec { buildPythonPackage rec {
pname = "rarfile"; pname = "rarfile";
version = "4.2"; version = "4.2";
format = "setuptools"; pyproject = true;
disabled = isPy27;
disabled = pythonOlder "3.6";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "markokr"; owner = "markokr";
repo = "rarfile"; repo = "rarfile";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
sha256 = "sha256-ZiwD2LG25fMd4Z+QWsh/x3ceG5QRBH4s/TZDwMnfpNI="; hash = "sha256-ZiwD2LG25fMd4Z+QWsh/x3ceG5QRBH4s/TZDwMnfpNI=";
}; };
nativeCheckInputs = [ pytestCheckHook nose glibcLocales ]; prePatch =
''
prePatch = '' substituteInPlace rarfile.py \
substituteInPlace rarfile.py \ ''
'' + (if useUnrar then + (
''--replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\"" if useUnrar then
'' ''
else --replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\""
''--replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\"" ''
'') else
+ ""; ''
# the tests only work with the standard unrar package --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; doCheck = useUnrar;
LC_ALL = "en_US.UTF-8";
pythonImportsCheck = [ "rarfile" ]; pythonImportsCheck = [ "rarfile" ];
meta = with lib; { meta = with lib; {
description = "RAR archive reader for Python"; description = "RAR archive reader for Python";
homepage = "https://github.com/markokr/rarfile"; homepage = "https://github.com/markokr/rarfile";
changelog = "https://github.com/markokr/rarfile/releases/tag/v${version}";
license = licenses.isc; license = licenses.isc;
maintainers = with maintainers; [ ];
}; };
} }