# 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 doc 1
%global python3_pkgversion 3.11
Name: python-aiosignal
Version: 1.3.1
Release: 2.ac13.py3.11%{?dist}
Summary: List of registered asynchronous callbacks
License: Apache-2.0
URL: https://github.com/aio-libs/aiosignal
Source: %{pypi_source aiosignal}
# Drop sphinxcontrib-asyncio doc dependency
# https://github.com/aio-libs/aiosignal/pull/528
# Rebased on the PyPI sdist, which lacks requirements/doc.txt
Patch: aiosignal-1.3.1-no-sphinxcontrib-asyncio.patch
BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}dist(pytest)
BuildRequires: python%{python3_pkgversion}dist(pytest-asyncio)
%if %{with doc}
BuildRequires: make
BuildRequires: python%{python3_pkgversion}dist(sphinx)
BuildRequires: python%{python3_pkgversion}-sphinx-latex
BuildRequires: latexmk
%endif
%global common_description %{expand:
A project to manage callbacks in asyncio projects.}
%description %{common_description}
%package -n python%{python3_pkgversion}-aiosignal
Summary: %{summary}
%description -n python%{python3_pkgversion}-aiosignal %{common_description}
%if %{with doc}
%package doc
Summary: Documentation for python-aiosignal
BuildArch: noarch
%description doc %{common_description}
%endif
%prep
%autosetup -n aiosignal-%{version} -p1
# Drop intersphinx mappings, since we can’t download remote inventories and
# can’t easily produce working hyperlinks from inventories in local
# documentation packages.
echo 'intersphinx_mapping.clear()' >> docs/conf.py
# Patch out coverage options
sed -r -i 's/--cov[^[:blank:]]*//g' setup.cfg
# Do not fail on warnings
sed -zi 's/filterwarnings = error/filterwarnings = default/' setup.cfg
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%if %{with doc}
%make_build -C docs latex \
SPHINXBUILD='sphinx-build-%{python3_pkgversion}' SPHINXOPTS='-j%{?_smp_build_ncpus}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif
%install
%pyproject_install
%pyproject_save_files aiosignal
%check
%pytest
for b in $(find %{buildroot}%{_bindir}/ -type f) ; do mv "$b" $(sed -re "s|(.*)$|\1-%{python3_pkgversion}|"<<<"$b"); done
for m in $(find %{buildroot}%{_mandir}/ -type f) ; do mv "$m" $(sed -re "s|(.*).([1-8])(.*)$|\1-%{python3_pkgversion}.\2\3|"<<<"$m"); done
for m in $(find %{buildroot}%{_datadir}/locale/* -type f) ; do mv "$m" $(sed -re "s|(.*).mo$|\1-%{python3_pkgversion}.mo|"<<<"$m"); done
for l in $(find %{buildroot}/usr/lib64/lib* -type f -o -type l) ; do mv "$l" $(sed -re "s|(.*).so(.*)$|\1-py%{python3_pkgversion}.so\2|"<<<"$l"); done
for p in $(find %{buildroot}/usr/lib64/pkgconfig/* -type f) ; do mv "$p" $(sed -re "s|(.*).pc$|\1-py%{python3_pkgversion}.pc|"<<<"$p"); done
%files -n python%{python3_pkgversion}-aiosignal -f %{pyproject_files}
%if %{without doc}
%doc CHANGES.rst CONTRIBUTORS.txt README.rst
%endif
%if %{with doc}
%files doc
%license LICENSE
%doc CHANGES.rst CONTRIBUTORS.txt README.rst
%doc docs/_build/latex/aiosignal.pdf
%endif
%changelog
* Wed Apr 17 2024 Ding-Yi Chen - 1.3.1-2.ac13.py3.11
- Cut corner packaging