## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 23;
    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 pypi_name managesieve

# Pull from GitLab (prerequisite for Packit)
%global forgeurl https://gitlab.com/htgoebel/managesieve

Name:           python-%{pypi_name}
Version:        0.7.1
Release:        %autorelease
Summary:        Accessing a Sieve-Server for managing Sieve scripts
%global tag v%{version}
%forgemeta
License:        PSF-2.0 AND GPL-3.0-only
URL:            https://managesieve.readthedocs.io/
Source0:        %forgesource
# ssl.wrap_socket is deprecated and Python 3.12 removed it entirely
# https://gitlab.com/htgoebel/managesieve/-/issues/8
Patch:          fix_ssl_wrap_socket_error.patch
BuildArch:      noarch

BuildRequires:  python3-devel, git-core
BuildRequires:  python3-pytest
BuildRequires:  make
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx_rtd_theme

%description
This module allows accessing a Sieve-Server for managing Sieve scripts there.
It is accompanied by a simple yet functional user application ‘sieveshell’.

%package -n     python3-%{pypi_name}
Summary:        %{summary}
# Package `cyrus-imapd-utils` also provides /usr/bin/sieveshell
# However `python-managesieve` provided a Python script installed at
# /usr/bin/sieveshell from its inception when version 0.6 was packaged
# in 2020. Upstream's HISTORY file documents it being present since 0.2
# released in 2004. Clearly this has been missed during package review.
# https://bugzilla.redhat.com/show_bug.cgi?id=2228002
Conflicts:      cyrus-imapd-utils

%description -n python3-%{pypi_name}
This module allows accessing a Sieve-Server for managing Sieve scripts there.
It is accompanied by a simple yet functional user application ‘sieveshell’.


%prep
%forgeautosetup -p1 -S git


%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files managesieve


%check
%pytest


%files -n python3-%{pypi_name} -f %{pyproject_files}
%license LICENSE
%doc README.txt HISTORY
%{_bindir}/sieveshell


%changelog
## START: Generated by rpmautospec
* Sat Oct 26 2024 Sandro <devel@penguinpee.nl> - 0.7.1-23
- Conflict cyrus-imapd-utils (RHBZ#2228002)

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.1-21
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 0.7.1-20
- Rebuilt for Python 3.13

* Mon Jan 29 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.1-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.1-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.1-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Nov 17 2023 Marius Hoch <mail@mariushoch.de> - 0.7.1-16
- Fix missing trailing newline in fix_ssl_wrap_socket_error.patch

* Thu Nov 16 2023 Marius Hoch <mail@mariushoch.de> - 0.7.1-15
- Fix fix_ssl_wrap_socket_error.patch

* Fri Nov 10 2023 Sandro <devel@penguinpee.nl> - 0.7.1-14
- Remove comment from %%check
- Align sections

* Fri Nov 10 2023 Sandro <devel@penguinpee.nl> - 0.7.1-13
- Add man pages

* Fri Nov 10 2023 Sandro <devel@penguinpee.nl> - 0.7.1-12
- Add Packit config

* Fri Nov 10 2023 Sandro <devel@penguinpee.nl> - 0.7.1-11
- Use forge macros and pull from GitLab

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

* Thu Jun 29 2023 Sandro <devel@penguinpee.nl> - 0.7.1-6
- Add missing changelog entries

* Thu Jun 29 2023 Sandro <devel@penguinpee.nl> - 0.7.1-5
- Migrate to SPDX license

* Thu Jun 29 2023 Sandro <devel@penguinpee.nl> - 0.7.1-4
- Fix ssl.wrap_socket AttributeError

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

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

* Fri Jan 6 2023 Steve Traylen <steve.traylen@cern.ch> - 0.7.1-1
- Update to 0.7.1
- LICENSE file now included in release
- Migrate to pyproject macros

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

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 0.6-9
- Rebuilt for Python 3.11

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

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.6-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.6-6
- Rebuilt for Python 3.10

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.6-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Nov 18 2020 Steve Traylen <steve.traylen@cern.ch> - 0.6-4
- Include LICENSE file

* Fri Nov 13 2020 Germano Massullo <germano.massullo@gmail.com> - 0.6-3
- rearranged %%check section
- added LICENSE file

* Wed Nov 11 2020 Steve Traylen <steve.traylen@cern.ch> - 0.6-2
- BR for pytest-runner for tests

* Thu Oct 29 2020 Steve Traylen <steve.traylen@cern.ch> - 0.6-1
- Initial release

## END: Generated by rpmautospec