## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 6;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global srcname b4

%if 0%{?fedora}
%bcond_without attest
%else
# some attestation dependencies not in EPEL
%bcond_with attest
%endif

Name:           python-%{srcname}
Version:        0.12.3
Release:        %autorelease
Summary:        A helper tool to work with public-inbox and patch series
License:        GPL-2.0-or-later
URL:            https://git.kernel.org/pub/scm/utils/%{srcname}/%{srcname}.git
Source0:        https://mirrors.edge.kernel.org/pub/software/devel/%{srcname}/%{srcname}-%{version}.tar.xz
Source1:        https://mirrors.edge.kernel.org/pub/software/devel/%{srcname}/%{srcname}-%{version}.tar.sign
# https://git.kernel.org/pub/scm/utils/b4/b4.git/plain/.keys/openpgp/linuxfoundation.org/konstantin/default
Source2:        gpgkey-DE0E66E32F1FDD0902666B96E63EDCA9329DD07E.asc

BuildArch:      noarch

BuildRequires:  gnupg2
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python3dist(pytest)

# Require manually until it provides python3dist(git-filter-repo)
# https://src.fedoraproject.orae57d6eg/rpms/git-filter-repo/pull-request/1
BuildRequires:  git-filter-repo > 2.30
Requires:       git-filter-repo > 2.30

%global _description %{expand:
B4 is a helper utility to work with patches made available via a public-inbox
archive like lore.kernel.org. It is written to make it easier to participate in
a patch-based workflows, like those used in the Linux kernel development.}

%description %{_description}


%package -n %{srcname}
Summary:        %{summary}
Provides:       python%{python3_pkgversion}-%{srcname} = %{version}-%{release}

%description -n %{srcname} %{_description}


%prep
xz -dc '%{SOURCE0}' | %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data=-
%autosetup -p1 -n %{srcname}-%{version}

# Disable attestation (only applicable to EPEL)
%if %{without attest}
sed -Ei -e '/^# These are optional, needed for attestation/d' \
    -e "/^ *'?(dnspython|dkimpy|patatt)/d" requirements.txt setup.py
%endif

# Avoid python3dist(git-filter-repo) requirement
sed -Ei "/^ *'?git-filter-repo/d" requirements.txt setup.py

%generate_buildrequires
%pyproject_buildrequires -r requirements.txt


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files %{srcname}


%check
%pyproject_check_import
# disable this test due to regression in 3.12b4:
# https://github.com/python/cpython/issues/106669
%pytest \
%if v"%{python3_version}" >= v"3.12"
  -k "not test_header_wrapping"
%endif


%files -n %{srcname} -f %{pyproject_files}
%license COPYING
%doc README.rst
%{_bindir}/%{srcname}
%{_mandir}/man5/%{srcname}.5.*


%changelog
## START: Generated by rpmautospec
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.12.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.12.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Wed Jul 26 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.12.3-4
- Skip test affected by Python 3.12b4 regression (rhbz#2226159)
- Also run %%%%pyproject_check_import

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.12.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue Jun 27 2023 Python Maint <python-maint@redhat.com> - 0.12.3-2
- Rebuilt for Python 3.12

* Mon Jun 26 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.12.3-1
- Update to 0.12.3 (closes: rhbz#2217072)

* Thu Jun 15 2023 Python Maint <python-maint@redhat.com> - 0.12.2-2
- Rebuilt for Python 3.12

* Thu May 18 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.12.2-1
- Update to 0.12.2

* Thu Feb 16 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.12.1-1
- Update to 0.12.1
- Patch to allow tests to run without a Git checkout
- Switch to SPDX license identifier
- Correct license, should be GPLv2+ / GPL-2.0-or-later

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Mon Oct 03 2022 Todd Zullinger <tmz@pobox.com> - 0.10.1-1
- update to 0.10.1

* Mon Oct 03 2022 Todd Zullinger <tmz@pobox.com> - 0.10.0-1
- update to 0.10.0

* Fri Sep 23 2022 Todd Zullinger <tmz@pobox.com> - 0.8.0-8
- verify signature of source tarball

* Tue Sep 20 2022 Todd Zullinger <tmz@pobox.com> - 0.8.0-7
- do not conditionalize patches

* Fri Jul 22 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.8.0-6
- Disable attestation on EPEL

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Tue Jun 14 2022 Python Maint <python-maint@redhat.com> - 0.8.0-4
- Rebuilt for Python 3.11

* Tue Mar 08 2022 Lumir Balhar <lbalhar@redhat.com> - 0.8.0-3
- Unpin dependency on dnspython

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Wed Dec 15 2021 Michel Alexandre Salim <salimma@fedoraproject.org> - 0.8.0-1
- Initial Fedora package
## END: Generated by rpmautospec