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