## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    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 _description %{expand:
The mailprocessing library contains two executables: maildirproc and
imapproc. maildirproc processes one or several several existing mail
boxes in the maildir format. It is primarily focused on mail sorting -
i.e., moving, copying, forwarding and deleting mail according to a set
of rules. It can be seen as an alternative to procmail, but instead of
being a delivery agent (which wants to be part of the delivery chain),
maildirproc only processes already delivered mail. And that's a
feature, not a bug. imapproc does the same thing for IMAP folders.}

Name:           mailprocessing
Version:        1.2.7
Release:        %autorelease
Summary:        Maildir and IMAP processor/filter

License:        GPL-2.0-only
URL:            https://github.com/mailprocessing/mailprocessing
Source0:        %{pypi_source %{name}}
# Fixes rpmlint incorrect-fsf-address error
# Patch from https://github.com/mailprocessing/mailprocessing/pull/14
Patch0:         fix-incorrect-fsf-address.patch

BuildArch:      noarch
BuildRequires:  python3-devel
BuildRequires:  make
BuildRequires:  git-core

Obsoletes:      maildirproc < 1.0.2
Provides:       maildirproc = %{version}-%{release}


%description %_description


%prep
%autosetup -p1 -n %{name}-%{version} -S git


%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel
pushd docs
  make
popd


%install
%pyproject_install
%pyproject_save_files %{name}
mkdir -p %{buildroot}%{_mandir}/man1
mkdir -p %{buildroot}%{_mandir}/man5
mv docs/*proc.1 %{buildroot}%{_mandir}/man1/
mv docs/%{name}.5 %{buildroot}%{_mandir}/man5/


%files -n %{name} -f %{pyproject_files}
%doc NEWS README
%doc docs/*html docs/*rst docs/examples docs/reference
%{_bindir}/imapproc
%{_bindir}/maildirproc
%{_mandir}/man1/*proc.1*
%{_mandir}/man5/%{name}*


%changelog
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

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

* Sun Jun 04 2023 Sandro <devel@penguinpee.nl> - 1.2.7-1
- Initial release of mailprocessing
- Rename of maildirproc following upstream
- Update to 1.2.7