%global python3_pkgversion 3.11
%global _description %{expand:
This is a little HTTP/1.1 library written from scratch in Python, heavily
inspired by hyper-h2.  It is a "bring-your-own-I/O" library; h11 contains no IO
code whatsoever.  This means you can hook h11 up to your favorite network API,
and that could be anything you want: synchronous, threaded, asynchronous, or
your own implementation of RFC 6214 -- h11 will not judge you.  This also means
that h11 is not immediately useful out of the box: it is a toolkit for building
programs that speak HTTP, not something that could directly replace requests or
twisted.web or whatever.  But h11 makes it much easier to implement something
like requests or twisted.web.}

Name:           python-h11
Version:        0.14.0
Release:        2.ac14.py3.11%{?dist}
Summary:        A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
License:        MIT
URL:            https://github.com/python-hyper/h11
Source0:        %{pypi_source h11}
BuildArch:      noarch


%description %{_description}


%package -n python%{python3_pkgversion}-h11
Summary:        %{summary}
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-pytest


%description -n python%{python3_pkgversion}-h11 %{_description}


%prep
%autosetup -n h11-%{version}


%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files h11


%check
%pytest h11


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}-h11 -f %{pyproject_files}
%doc README.rst


%changelog
* Thu Apr 18 2024 Ding-Yi Chen <dingyichen@gmail.com> -  0.14.0-2.ac14.py3.11
 - Cut corner packaging