at master 1.3 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pytestCheckHook, 6 libarchive, 7 pythonOlder, 8 setuptools, 9 # unrar is non-free software 10 useUnrar ? false, 11 unrar, 12}: 13 14assert useUnrar -> unrar != null; 15assert !useUnrar -> libarchive != null; 16 17buildPythonPackage rec { 18 pname = "rarfile"; 19 version = "4.2"; 20 pyproject = true; 21 22 disabled = pythonOlder "3.6"; 23 24 src = fetchFromGitHub { 25 owner = "markokr"; 26 repo = "rarfile"; 27 tag = "v${version}"; 28 hash = "sha256-ZiwD2LG25fMd4Z+QWsh/x3ceG5QRBH4s/TZDwMnfpNI="; 29 }; 30 31 prePatch = '' 32 substituteInPlace rarfile.py \ 33 '' 34 + ( 35 if useUnrar then 36 '' 37 --replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\"" 38 '' 39 else 40 '' 41 --replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\"" 42 '' 43 ) 44 + ""; 45 46 build-system = [ setuptools ]; 47 48 nativeCheckInputs = [ pytestCheckHook ]; 49 50 # The tests only work with the standard unrar package 51 doCheck = useUnrar; 52 53 pythonImportsCheck = [ "rarfile" ]; 54 55 meta = with lib; { 56 description = "RAR archive reader for Python"; 57 homepage = "https://github.com/markokr/rarfile"; 58 changelog = "https://github.com/markokr/rarfile/releases/tag/v${version}"; 59 license = licenses.isc; 60 maintainers = [ ]; 61 }; 62}