#
# spec file for package python-adblock
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define skip_python36 1
Name:           python-adblock
Version:        0.6.0
Release:        2.4
Summary:        Brave's adblock library in Python
License:        Apache-2.0 OR MIT
URL:            https://pypi.org/project/adblock/
Source:         https://github.com/ArniDagur/python-adblock/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.xz
Source2:        cargo_config
# PATCH-FIX-OPENSUSE allow building with newer maturin, which is pedantic about PEP 621
Patch0:         python-adblock-maturin-0-14-compat.patch
BuildRequires:  python%{python3_pkgversion}dist(maturin)
BuildRequires:  python%{python3_pkgversion}dist(pip)
BuildRequires:  python%{python3_pkgversion}dist(setuptools)
%if %{python3_version_nodots} < 311
BuildRequires:  python%{python3_pkgversion}dist(toml)
%endif
BuildRequires:  rust-packaging
BuildRequires:  python3-rpm-macros
ExclusiveArch:  %{rust_arches}

%description
Python wrapper for Brave's adblocking library.


%package -n python%{python3_pkgversion}-adblock
Summary: Brave's adblock library in Python

%description -n python%{python3_pkgversion}-adblock
Python wrapper for Brave's adblocking library.


%prep
%autosetup -a1 -p1
# build flavor-specific versions -- otherwise wheels will not work
sed -i 's/"abi3-py37", //' Cargo.toml
mkdir .cargo
cp %{SOURCE2} .cargo/config

%build
%pyproject_wheel

%install
%pyproject_install

%check

%files -n python%{python3_pkgversion}-adblock
%license LICENSE-APACHE LICENSE-MIT
%doc CHANGELOG.md README.md
%{python3_sitearch}/*

%changelog
* Tue Mar 28 2023 Mia Herkt <mia@0x0.st>
- Update vendor tarball
- Add python-adblock-maturin-0-14-compat.patch
  Allow building with newer maturin, which is pedantic about
  PEP 621
* Sun Jul 24 2022 Mia Herkt <mia@0x0.st>
- Update to 0.6.0
  Added
  * Added aliases optional argument to Engine.add_resource.
  Changes
  * Update PyO3 dependency to 0.16.
  * Update upstream dependency to 0.5.6.
  Breaks
  * Minimum Rust version is now 1.53.
  * Minimum Python version is now 3.7.
* Wed Jun 15 2022 Mia Herkt <mia@0x0.st>
- Update to 0.5.2
  * Include complete redirect rule feature
    (gh#ArniDagur/python-adblock#59)
* Wed Feb  2 2022 Mia Herkt <mia@0x0.st>
- Update to 0.5.1
  * Fix test suite for Python 3.10
* Fri Nov  5 2021 William Brown <william.brown@suse.com>
- Add cargo audit service to detect potential security issues
* Thu Sep 30 2021 William Brown <william.brown@suse.com>
- Replace rust-packaging with cargo-packaging
* Sun Jun 27 2021 Mia Herkt <mia@0x0.st>
- Update to 0.5.0
  * Library now throws the custom adblock.AdblockException
    exception, instead of ValueError.
* Tue Apr 20 2021 Mia Herkt <mia@0x0.st>
- init, 0.4.4
