at 25.11-pre 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 buildPythonPackage, 7 rustPlatform, 8 pkg-config, 9 openssl, 10 publicsuffix-list, 11 pythonOlder, 12 libiconv, 13 pytestCheckHook, 14 toml, 15}: 16 17buildPythonPackage rec { 18 pname = "adblock"; 19 version = "0.6.0"; 20 format = "pyproject"; 21 22 disabled = pythonOlder "3.7"; 23 24 # Pypi only has binary releases 25 src = fetchFromGitHub { 26 owner = "ArniDagur"; 27 repo = "python-adblock"; 28 tag = version; 29 hash = "sha256-5g5xdUzH/RTVwu4Vfb5Cb1t0ruG0EXgiXjrogD/+JCU="; 30 }; 31 32 patches = [ 33 # https://github.com/ArniDagur/python-adblock/pull/91 34 (fetchpatch { 35 name = "pep-621-compat.patch"; 36 url = "https://github.com/ArniDagur/python-adblock/commit/2a8716e0723b60390f0aefd0e05f40ba598ac73f.patch"; 37 hash = "sha256-n9+LDs0no66OdNZxw3aU57ngWrAbmm6hx4qIuxXoatM="; 38 }) 39 ]; 40 41 postPatch = '' 42 substituteInPlace pyproject.toml \ 43 --replace "0.0.0" "${version}" 44 ''; 45 46 cargoDeps = rustPlatform.fetchCargoVendor { 47 inherit src; 48 name = "${pname}-${version}"; 49 hash = "sha256-fetJX6HQxRZ/Az7rJeU9S+s8ttgNPnJEvTLfzGt4xjk="; 50 }; 51 52 nativeBuildInputs = 53 [ pkg-config ] 54 ++ (with rustPlatform; [ 55 cargoSetupHook 56 maturinBuildHook 57 ]); 58 59 buildInputs = 60 [ openssl ] 61 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 62 libiconv 63 ]; 64 65 PSL_PATH = "${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat"; 66 67 nativeCheckInputs = [ 68 pytestCheckHook 69 toml 70 ]; 71 72 preCheck = '' 73 # import from $out instead 74 rm -r adblock 75 ''; 76 77 disabledTestPaths = [ 78 # relies on directory removed above 79 "tests/test_typestubs.py" 80 ]; 81 82 pythonImportsCheck = [ 83 "adblock" 84 "adblock.adblock" 85 ]; 86 87 meta = with lib; { 88 description = "Python wrapper for Brave's adblocking library"; 89 homepage = "https://github.com/ArniDagur/python-adblock/"; 90 changelog = "https://github.com/ArniDagur/python-adblock/blob/${version}/CHANGELOG.md"; 91 maintainers = with maintainers; [ dotlambda ]; 92 license = with licenses; [ 93 asl20 # or 94 mit 95 ]; 96 }; 97}