Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / adblock / default.nix
blob87f42fbd35b6ef51672520198877d60caa1fafeb
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
18 buildPythonPackage rec {
19   pname = "adblock";
20   version = "0.6.0";
21   format = "pyproject";
23   disabled = pythonOlder "3.7";
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   };
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   ];
42   postPatch = ''
43     substituteInPlace pyproject.toml \
44       --replace "0.0.0" "${version}"
45   '';
47   cargoDeps = rustPlatform.fetchCargoTarball {
48     inherit src;
49     name = "${pname}-${version}";
50     hash = "sha256-1xmYmF5P7a5O9MilxDy+CVhmWMGRetdM2fGvTPy7JmM=";
51   };
53   nativeBuildInputs = [
54     pkg-config
55   ] ++ (with rustPlatform; [
56     cargoSetupHook
57     maturinBuildHook
58   ]);
60   buildInputs = [
61     openssl
62   ] ++ lib.optionals stdenv.isDarwin [
63     libiconv
64     CoreFoundation
65     Security
66   ];
68   PSL_PATH = "${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat";
70   nativeCheckInputs = [
71     pytestCheckHook
72     toml
73   ];
75   preCheck = ''
76     # import from $out instead
77     rm -r adblock
78   '';
80   disabledTestPaths = [
81     # relies on directory removed above
82     "tests/test_typestubs.py"
83   ];
85   pythonImportsCheck = [
86     "adblock"
87     "adblock.adblock"
88   ];
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   };