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

# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf

Name:           python-flask-socketio
Version:        5.3.1
Release:        %autorelease
Summary:        Socket.IO integration for Flask applications

# SPDX
License:        MIT
URL:            https://github.com/miguelgrinberg/Flask-SocketIO/
Source0:        %{url}/archive/v%{version}/Flask-SocketIO-%{version}.tar.gz

BuildArch:      noarch
 
BuildRequires:  python3-devel

# Documentation
%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
%endif

%global common_description %{expand:
Flask-SocketIO gives Flask applications access to low latency bi-directional
communications between the clients and the server. The client-side application
can use any of the SocketIO official clients libraries in Javascript, C++, Java
and Swift, or any compatible client to establish a permanent connection to the
server.}

%description %{common_description}


%package -n     python3-flask-socketio
Summary:        %{summary}

%description -n python3-flask-socketio %{common_description}


%package        doc
Summary:        Documentation for %{name}

%description    doc %{common_description}


%prep
%autosetup -n Flask-SocketIO-%{version}
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
sed -r -i \
    -e 's/--cov[^[:blank:]]*//g' \
    -e '/^[[:blank:]]*(pytest-cov)[[:blank:]]*$/d' \
    tox.ini


%generate_buildrequires
%pyproject_buildrequires -t


%build
%pyproject_wheel
%if %{with doc_pdf}
PYTHONPATH="${PWD}/src" %make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif


%install
%pyproject_install
%pyproject_save_files flask_socketio


%check
# Because of its name, flask_socketio.test_client is mistaken for a test; then,
# pytest fails because of an import path mismatch, since that module is
# available both here in the build directory and in the buildroot. Simply
# ignoring it in test collection is perfectly correct and solves the problem.
%pytest --ignore-glob='*/test_client.py'


%files -n python3-flask-socketio -f %{pyproject_files}


%files doc
%license LICENSE
%doc CHANGES.md
%doc README.md
%doc SECURITY.md
%if %{with doc_pdf}
%doc docs/_build/latex/flask-socketio.pdf
%endif
%doc example


%changelog
* Tue Sep 13 2022 Sandro Mani <manisandro@gmail.com> 5.3.1-1
- Update to 5.3.1

* Wed Aug 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.3.0-1
- Update to 5.3.0 (close RHBZ#2120862)

* Wed Aug 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.2.0-4
- Confirm License is SPDX MIT

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

* Sun May 22 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.2.0-2
- Patch out pytest-cov

* Sun May 22 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.2.0-1
- Update to 5.2.0 (close RHBZ#2089038)

* Sun Apr 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.2-1
- Update to 5.1.2 (close RHBZ#2078202)

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

* Fri Nov 26 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-8
- Reduce LaTeX PDF build verbosity

* Thu Sep 30 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-7
- Fix Rawhide EVR lagging F35 (oops)

* Thu Sep 30 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-6
- Fix PYTHONPATH when building docs

* Thu Sep 30 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-5
- Generate PDF instead of HTML Sphinx documentation.

* Mon Sep 13 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-4
- Let pyproject-rpm-macros handle the license file

* Sun Sep 12 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-3
- Drop BR on pyproject-rpm-macros, now implied by python3-devel

* Sun Sep 12 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-2
- Reduce macro indirection in the spec file

* Mon Aug 02 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.1-1
- Update to 5.1.1 (fixes RHBZ#1988874)

* Tue Jul 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.0-2
- Move %%generate_buildrequires after %%prep to make the spec file easier
  to follow

* Wed Jul 21 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.1.0-1
- Update to 5.1.0 (closes RHBZ#1979423)

* Mon Jul 05 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 4.3.2-1
- Update to 4.3.2
- Near-total spec file rewrite
- Remove obsolete practices like python_provide macro and manual Requires
- Add documentation subpackage
- Use pytest as test runner
- Fix spurious executable permissions (upstream PR#748)

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

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

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue May 26 2020 Miro HronĨok <mhroncok@redhat.com> - 4.2.1-4
- Rebuilt for Python 3.9

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Tue Dec 31 2019 Mukundan Ragavan <nonamedotc@fedoraproject.org> - 4.2.1-2
- Use expand macro for description

* Sun Dec 22 2019 Mukundan Ragavan <nonamedotc@gmail.com> - 4.2.1-1
- Initial package.