1{ stdenv
2, lib
3, fetchFromGitHub
4, buildPythonPackage
5, rustPlatform
6, pythonImportsCheckHook
7, pkg-config
8, openssl
9, publicsuffix-list
10, isPy27
11, CoreFoundation
12, Security
13}:
14
15buildPythonPackage rec {
16 pname = "adblock";
17 version = "0.4.0";
18 disabled = isPy27;
19
20 # Pypi only has binary releases
21 src = fetchFromGitHub {
22 owner = "ArniDagur";
23 repo = "python-adblock";
24 rev = version;
25 sha256 = "10d6ks2fyzbizq3kb69q478idj0h86k6ygjb6wl3zq3mf65ma4zg";
26 };
27
28 cargoDeps = rustPlatform.fetchCargoTarball {
29 inherit src;
30 name = "${pname}-${version}";
31 hash = "sha256-gEFmj3/KvhvvsOK2nX2L1RUD4Wfp3nYzEzVnQZIsIDY=";
32 };
33
34 format = "pyproject";
35
36 nativeBuildInputs = [ pkg-config pythonImportsCheckHook ]
37 ++ (with rustPlatform; [ cargoSetupHook maturinBuildHook ]);
38
39 buildInputs = [ openssl ]
40 ++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ];
41
42 PSL_PATH = "${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat";
43
44 # There are no rust tests
45 doCheck = false;
46
47 pythonImportsCheck = [ "adblock" ];
48
49 meta = with lib; {
50 description = "Python wrapper for Brave's adblocking library, which is written in Rust";
51 homepage = "https://github.com/ArniDagur/python-adblock/";
52 maintainers = with maintainers; [ petabyteboy ];
53 license = with licenses; [ asl20 mit ];
54 };
55}