1{ stdenv
2, lib
3, fetchFromGitHub
4, buildPythonPackage
5, rustPlatform
6, pkg-config
7, openssl
8, publicsuffix-list
9, isPy27
10, libiconv
11, CoreFoundation
12, Security
13, pytestCheckHook
14, toml
15}:
16
17buildPythonPackage rec {
18 pname = "adblock";
19 version = "0.5.0";
20 disabled = isPy27;
21
22 # Pypi only has binary releases
23 src = fetchFromGitHub {
24 owner = "ArniDagur";
25 repo = "python-adblock";
26 rev = version;
27 sha256 = "sha256-JjmMfL24778T6LCuElXsD7cJxQ+RkqbNEnEqwoN24WE=";
28 };
29
30 cargoDeps = rustPlatform.fetchCargoTarball {
31 inherit src;
32 name = "${pname}-${version}";
33 hash = "sha256-w+/W4T3ukRHNpCPjhlHZLPn6sgCpz4QHVD8VW+Rw5BI=";
34 };
35
36 format = "pyproject";
37
38 nativeBuildInputs = [ pkg-config ]
39 ++ (with rustPlatform; [ cargoSetupHook maturinBuildHook ]);
40
41 buildInputs = [ openssl ]
42 ++ lib.optionals stdenv.isDarwin [ libiconv CoreFoundation Security ];
43
44 PSL_PATH = "${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat";
45
46 checkInputs = [ pytestCheckHook toml ];
47
48 preCheck = ''
49 # import from $out instead
50 rm -r adblock
51 '';
52
53 disabledTestPaths = [
54 # relies on directory removed above
55 "tests/test_typestubs.py"
56 ];
57
58 pythonImportsCheck = [ "adblock" "adblock.adblock" ];
59
60 meta = with lib; {
61 description = "Python wrapper for Brave's adblocking library, which is written in Rust";
62 homepage = "https://github.com/ArniDagur/python-adblock/";
63 maintainers = with maintainers; [ petabyteboy dotlambda ];
64 license = with licenses; [ asl20 mit ];
65 };
66}