## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 5;
    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

# 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-socketio
Version:        5.7.2
Release:        %autorelease
Summary:        Socket.IO server

# SPDX
License:        MIT
URL:            https://github.com/miguelgrinberg/python-socketio
Source0:        %{url}/archive/v%{version}/python-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

# Extra testing dependencies
BuildRequires:  python3dist(pytest)

%global common_description %{expand:
Socket.IO is a transport protocol that enables real-time bidirectional
event-based communication between clients (typically, though not always, web
browsers) and a server. The official implementations of the client and server
components are written in JavaScript. This package provides Python
implementations of both, each with standard and asyncio variants.}

%description %{common_description}


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

%description -n python3-socketio %{common_description}


%pyproject_extras_subpkg -n python3-socketio client asyncio_client


%package        doc
Summary:        Documentation for python-socketio

%description    doc %{common_description}


%prep
%autosetup
# Fix “/usr/bin/env python” shebangs in the examples
%py3_shebang_fix examples
# Don’t ship package-lock.json files with the examples. Overzealous bug-filing
# scripts will file issues on this project for CVE’s in the recursive
# dependencies mentioned there even though they are not present in or used by
# this package at all.
find examples -type f -name package-lock.json -print -delete


%generate_buildrequires
%pyproject_buildrequires -x client,asyncio_client -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 socketio


%check
%pytest


%files -n python3-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/python-socketio.pdf
%endif
%doc examples/


%changelog
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> 5.7.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Wed Dec 21 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.7.2-4
- Indicate dirs. in files list with trailing slashes

* Wed Nov 23 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.7.2-3
- Strip package-lock.json files from the examples

* Wed Nov 23 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.7.2-2
- Confirm license is SPDX MIT

* Mon Oct 17 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.7.2-1
- Update to 5.7.2 (close RHBZ#2135313)

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

* Sat Jul 16 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.7.1-1
- Update to 5.7.1 (close RHBZ#2107761)

* Thu Jul 14 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.7.0-1
- Update to 5.7.0 (close RHBZ#2103685)

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

* Tue Feb 15 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.5.2-1
- Update to 5.5.2 (close RHBZ#2054647)

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

* Wed Jan 12 2022 Benjamin A. Beasley <code@musicinmybrain.net> 5.5.1-1
- Update to 5.5.1 (close RHBZ#2039293)

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

* Sun Nov 14 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.5.0-1
- Update to 5.5.0 (close RHBZ#2023066)

* Fri Oct 15 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.4.1-1
- Update to 5.4.1

* Fri Oct 01 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.4.0-6
- Fix PYTHONPATH when building documentation

* Wed Sep 29 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.4.0-5
- Generate PDF instead of HTML Sphinx documentation.

* Sun Sep 12 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.4.0-4
- Let pyproject-rpm-mmacros handle the license file

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

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

* Mon Aug 02 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.4.0-1
- Update to 5.4.0

* Tue Jul 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> 5.3.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.3.0-1
- Update to 5.3.0 (closes RHBZ#1875537)

* Mon Jul 05 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 4.6.1-1
- Update to 4.6.1
- 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.6.0-3
- Rebuilt for Python 3.10

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

* Thu Sep 03 2020 Mukundan Ragavan <nonamedotc@fedoraproject.org> - 4.6.0-1
- Update to 4.6.0

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

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

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

* Mon Dec 30 2019 Mukundan Ragavan <nonamedotc@fedoraproject.org> - 4.4.0-2
- Use expand macro for description

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