1 %define crates_ver 0.4.4
4 Summary: Brave's adblock library in Python
5 Name: python3-%{module}
8 License: MIT or Apache v2.0
9 Group: Libraries/Python
10 Source0: https://files.pythonhosted.org/packages/source/a/adblock/%{module}-%{version}.tar.gz
11 # Source0-md5: 6958de33e5034c1241a69c91989f0e86
13 Source1: %{name}-crates-%{crates_ver}.tar.xz
14 # Source1-md5: 932c699a7fa6016098e56026ae389322
15 URL: https://github.com/ArniDagur/python-adblock
17 BuildRequires: maturin >= 0.10
18 BuildRequires: python3-devel >= 1:3.6
19 BuildRequires: rpm-pythonprov
20 BuildRequires: rpmbuild(macros) >= 2.004
21 BuildRequires: rust >= 1.45
22 ExclusiveArch: %{rust_arches}
23 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
26 %define cargo_outdir target/x86_64-unknown-linux-gnux32
28 %define cargo_outdir target
32 Python wrapper for Brave's adblocking library, which is written in
36 %setup -q -n %{module}-%{version} -a1
38 %{__mv} %{module}-%{crates_ver}/* .
39 sed -i -e 's/@@VERSION@@/%{version}/' Cargo.lock
41 # use our offline registry
42 export CARGO_HOME="$(pwd)/.cargo"
44 mkdir -p "$CARGO_HOME"
45 cat >.cargo/config <<EOF
47 registry = 'https://github.com/rust-lang/crates.io-index'
48 replace-with = 'vendored-sources'
50 [source.vendored-sources]
51 directory = '$PWD/vendor'
55 export CARGO_HOME="$(pwd)/.cargo"
56 export CARGO_NET_OFFLINE=true
57 export CARGO_TERM_VERBOSE=true
58 %{?__jobs:export CARGO_BUILD_JOBS="%{__jobs}"}
59 export RUSTFLAGS="%{rpmrustflags}"
61 export RUSTFLAGS="$RUSTFLAGS -C opt-level=1"
63 /usr/bin/maturin build --release --no-sdist \
65 --target x86_64-unknown-linux-gnux32
69 rm -rf $RPM_BUILD_ROOT
71 install -d $RPM_BUILD_ROOT%{py3_sitedir}
72 cp -p %{cargo_outdir}/release/libadblock.so $RPM_BUILD_ROOT%{py3_sitedir}/%{module}.so
75 rm -rf $RPM_BUILD_ROOT
77 %files -n python3-%{module}
78 %defattr(644,root,root,755)
79 %doc CHANGELOG.md README.md
80 %attr(755,root,root) %{py3_sitedir}/%{module}.so