2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-01-05 17:05:55 +00:00
|
|
|
, fetchFromGitHub
|
2023-03-04 12:14:45 +00:00
|
|
|
, fetchpatch
|
2021-03-09 03:18:52 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, rustPlatform
|
2021-01-05 17:05:55 +00:00
|
|
|
, pkg-config
|
|
|
|
, openssl
|
|
|
|
, publicsuffix-list
|
2021-12-06 16:07:01 +00:00
|
|
|
, pythonOlder
|
2021-06-04 09:07:49 +00:00
|
|
|
, libiconv
|
2021-01-05 17:05:55 +00:00
|
|
|
, CoreFoundation
|
|
|
|
, Security
|
2021-06-28 23:13:55 +00:00
|
|
|
, pytestCheckHook
|
|
|
|
, toml
|
2021-01-05 17:05:55 +00:00
|
|
|
}:
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
buildPythonPackage rec {
|
2021-01-05 17:05:55 +00:00
|
|
|
pname = "adblock";
|
2022-08-21 13:32:41 +00:00
|
|
|
version = "0.6.0";
|
2021-12-06 16:07:01 +00:00
|
|
|
format = "pyproject";
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2021-01-05 17:05:55 +00:00
|
|
|
|
|
|
|
# Pypi only has binary releases
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ArniDagur";
|
|
|
|
repo = "python-adblock";
|
2022-04-15 01:41:22 +00:00
|
|
|
rev = "refs/tags/${version}";
|
2022-08-21 13:32:41 +00:00
|
|
|
hash = "sha256-5g5xdUzH/RTVwu4Vfb5Cb1t0ruG0EXgiXjrogD/+JCU=";
|
2021-01-05 17:05:55 +00:00
|
|
|
};
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
patches = [
|
|
|
|
# https://github.com/ArniDagur/python-adblock/pull/91
|
|
|
|
(fetchpatch {
|
|
|
|
name = "pep-621-compat.patch";
|
|
|
|
url = "https://github.com/ArniDagur/python-adblock/commit/2a8716e0723b60390f0aefd0e05f40ba598ac73f.patch";
|
|
|
|
hash = "sha256-n9+LDs0no66OdNZxw3aU57ngWrAbmm6hx4qIuxXoatM=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace pyproject.toml \
|
|
|
|
--replace "0.0.0" "${version}"
|
|
|
|
'';
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
name = "${pname}-${version}";
|
2022-08-21 13:32:41 +00:00
|
|
|
hash = "sha256-1xmYmF5P7a5O9MilxDy+CVhmWMGRetdM2fGvTPy7JmM=";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
] ++ (with rustPlatform; [
|
|
|
|
cargoSetupHook
|
|
|
|
maturinBuildHook
|
|
|
|
]);
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildInputs = [
|
|
|
|
openssl
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
libiconv
|
|
|
|
CoreFoundation
|
|
|
|
Security
|
|
|
|
];
|
2021-01-05 17:05:55 +00:00
|
|
|
|
|
|
|
PSL_PATH = "${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat";
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-12-06 16:07:01 +00:00
|
|
|
pytestCheckHook
|
|
|
|
toml
|
|
|
|
];
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
preCheck = ''
|
|
|
|
# import from $out instead
|
|
|
|
rm -r adblock
|
|
|
|
'';
|
|
|
|
|
|
|
|
disabledTestPaths = [
|
|
|
|
# relies on directory removed above
|
|
|
|
"tests/test_typestubs.py"
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"adblock"
|
|
|
|
"adblock.adblock"
|
|
|
|
];
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
meta = with lib; {
|
2021-12-06 16:07:01 +00:00
|
|
|
description = "Python wrapper for Brave's adblocking library";
|
2021-01-05 17:05:55 +00:00
|
|
|
homepage = "https://github.com/ArniDagur/python-adblock/";
|
2023-03-24 00:07:29 +00:00
|
|
|
changelog = "https://github.com/ArniDagur/python-adblock/blob/${version}/CHANGELOG.md";
|
2022-07-14 12:49:19 +00:00
|
|
|
maintainers = with maintainers; [ dotlambda ];
|
2021-12-06 16:07:01 +00:00
|
|
|
license = with licenses; [ asl20 /* or */ mit ];
|
2021-01-05 17:05:55 +00:00
|
|
|
};
|
|
|
|
}
|