Name:           python-httptools
Version:        0.2.0
Release:        4%{?dist}
Summary:        Fast HTTP parser

# httptools is MIT
# llhttp is MIT
# http-parser is MIT (unused but kept in this list for reference)
License:        MIT
URL:            https://github.com/MagicStack/httptools

# We use 2 similar source tarballs, each of them containing some additional stuff
# In %%prep they are unpacked to the same target directory
# The sdist from PyPI does not contain tests:
Source0:        %{pypi_source httptools}
# The GitHub tarball does not contain git submodules with vendored libraries:
Source1:        %{url}/archive/v%{version}/httptools-git-%{version}.tar.gz


BuildRequires:  gcc
BuildRequires:  http-parser-devel
BuildRequires:  python3-devel

%global _description %{expand:
The httptools module is a Python binding for the nodejs HTTP parser.

It contains two classes: httptools.HttpRequestParser,
httptools.HttpResponseParser (fulfilled through llhttp) and a function for
parsing URLs httptools.parse_url.}

%description %{_description}

%package -n python3-httptools
Summary:        %{summary}
Provides:       bundled(llhttp) = 4.0.0

%description -n python3-httptools %_description


%prep
%autosetup -p1 -b1 -n httptools-%{version}
# Allow newer Cython
sed -i 's/Cython==0.29.22/Cython>=0.29.22,<3/' setup.py

# Remove pregenerated Cython C sources
rm $(grep -rl '/\* Generated by Cython')

# Do not install *.c sources
# https://github.com/MagicStack/httptools/pull/73
sed -i 's/include_package_data=True/include_package_data=False/' setup.py

# Move the vendored license to a better name
mv vendor/llhttp/LICENSE-MIT LICENSE.llhttp

# Use system http-parser
sed -i 's/use_system_http_parser = False/use_system_http_parser = True/' setup.py
rm -r vendor/http-parser


%generate_buildrequires
# NB: At least in 0.20 and 0.3.0 the [test] extra installs only Cython :/
%pyproject_buildrequires -rx test


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files httptools


%check
# do not attempt to import from $PWD
mv httptools _httptools
export PYTHONPATH=%{buildroot}%{python3_sitearch}

%{python3} -m unittest -v tests.suite

# cleanup
mv _httptools httptools


%files -n python3-httptools -f %{pyproject_files}
%doc README.md


%changelog
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

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

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

* Fri Sep 10 2021 Miro Hrončok <mhroncok@redhat.com> - 0.2.0-1
- Update to 0.2.0
- Now bundles llhttp

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

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

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

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

* Thu Jun 18 2020 Itamar Reis Peixoto <itamar@ispbrasil.com.br> - 0.1.0-1
- Update to 0.1.0

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

* Wed Apr 15 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 0.0.11-8
- Rebuild for http-parser 2.9.4

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

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 0.0.11-6
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.0.11-5
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.11-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Sun Jul 08 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.0.11-1
- Update to 0.0.11

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.0.10-3
- Rebuilt for Python 3.7

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.10-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Sun Dec 31 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.0.10-1
- Update to 0.0.10

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.9-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.9-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Tue Jan 03 2017 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.0.9-2
- Drop python2 subpackage

* Sun Jan 01 2017 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.0.9-1
- Initial package