## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-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*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Not building on EPEL 7 as several deps aren't available

%global modname httpbin

%global desc Testing an HTTP Library can become difficult sometimes. RequestBin is \
fantastic for testing POST requests, but doesn't let you control the response. \
This exists to cover all kinds of HTTP scenarios. Additional endpoints are \
being considered. All endpoint responses are JSON-encoded.

Name:           python-%{modname}
Version:        0.10.2
Release:        %autorelease
Summary:        HTTP Request & Response Service, written in Python + Flask

License:        MIT
URL:            https://github.com/psf/httpbin
Source:         https://files.pythonhosted.org/packages/source/h/%{modname}/%{modname}-%{version}.tar.gz
# https://github.com/psf/httpbin/issues/26
# https://github.com/psf/httpbin/pull/32
# Make the dependency on flasgger optional - it has a heavy dep chain
# of its own and is hard to package, and is not needed for using
# httpbin as a library
Patch:          0001-Make-flasgger-dep-optional-26.patch
# https://github.com/psf/httpbin/pull/34
# Replace use of a deprecated Flask config setting
Patch:          0001-Replace-deprecated-JSONIFY_PRETTYPRINT_REGULAR-usage.patch
# https://github.com/psf/httpbin/pull/41
# Fix /bytes endpoint with newer werkzeug versions
Patch:          0001-Fix-bytes-endpoint-with-newer-werkzeug-versions.patch
BuildArch:      noarch

%description
%{desc}

%package -n python3-%{modname}
Summary:        %{summary}
BuildRequires:  python3-devel
BuildRequires:  python3dist(pytest)

%description -n python3-%{modname}
%{desc}.

%prep
%autosetup -n %{modname}-%{version} -p1

# Use the Google 'brotli' module, not 'brotlipy'
# When I asked why this uses brotlipy, upstream (Cory Benfield) said:
# "The upstream Brotli module is a hand-coded C extension to Python.
# This has a number of downsides, but the major one is that it ruins
# performance xon PyPy. As an avid user of PyPy, I want something I can
# deploy there. Hence: brotlipy, which uses CFFI."
# For me that's not enough of a reason to bother packaging it.
sed -i -e 's/brotlicffi/brotli/' httpbin/filters.py
sed -i -e 's/brotlicffi/brotli/' pyproject.toml

%generate_buildrequires
%pyproject_buildrequires

# no need for this to be executable
# https://github.com/psf/httpbin/pull/22
chmod ugo-x httpbin/templates/forms-post.html

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{modname}

%check
%pytest

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

%changelog
## START: Generated by rpmautospec
* Fri Mar 22 2024 Adam Williamson <awilliam@redhat.com> - 0.10.2-1
- Update to 0.10.2, drop merged patch

* Fri Jan 26 2024 Scott Talbert <swt@techie.net> - 0.10.1-6
- Fix /bytes endpoint with newer werkzeug versions

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Thu Dec 07 2023 František Zatloukal <fzatlouk@redhat.com> - 0.10.1-3
- Backport Flask/Werkzeug 3 support PR

* Wed Oct 18 2023 Adam Williamson <awilliam@redhat.com> - 0.10.1-2
- Backport PR #34 to fix use of deprecated Flask option

* Wed Oct 18 2023 Adam Williamson <awilliam@redhat.com> - 0.10.1-1
- Update to 0.10.1, backport patch to make flasgger optional

* Mon Aug 21 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 0.10.0-1
- Update to 0.10.0
- Switch to psf fork
- Adopt rpmautospec
- Adopt pyproject-rpm-macros
- Misc clean-ups

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.0-24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Fri Jun 16 2023 Python Maint <python-maint@redhat.com> - 0.7.0-23
- Rebuilt for Python 3.12

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.0-22
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Sep 15 2022 Adam Williamson <awilliam@redhat.com> - 0.7.0-21
- Don't apply patches for modern werkzeug on EPEL 8

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

* Tue Jun 14 2022 Python Maint <python-maint@redhat.com> - 0.7.0-19
- Rebuilt for Python 3.11

* Thu May 05 2022 Adam Williamson <awilliam@redhat.com> - 0.7.0-18
- Update patch from 0.7.0-15 to work with werkzeug 2.1.0+

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

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

* Mon Jul 19 2021 Adam Williamson <awilliam@redhat.com> - 0.7.0-15
- Fix Location header autocorrect disabling with werkzeug >= 2.0.0

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

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

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

* Sun May 24 2020 Miro Hrončok <mhroncok@redhat.com> - 0.7.0-11
- Rebuilt for Python 3.9

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

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

* Sat Aug 17 2019 Miro Hrončok <mhroncok@redhat.com> - 0.7.0-8
- Rebuilt for Python 3.8

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

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

* Fri Nov 23 2018 Adam Williamson <awilliam@redhat.com> - 0.7.0-5
- Disable Python 2 build on F30+, EL8+
- Drop all the EPEL compat stuff for now as we can't build for EPEL

* Sun Nov 18 2018 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.7.0-4
- Drop explicit locale setting
  See https://fedoraproject.org/wiki/Changes/Remove_glibc-langpacks-all_from_buildroot

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

* Mon Jun 18 2018 Miro Hrončok <mhroncok@redhat.com> - 0.7.0-2
- Rebuilt for Python 3.7

* Thu May 10 2018 Adam Williamson <awilliam@redhat.com> - 0.7.0-1
- Update to 0.7.0, drop merged patch, update requirements

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

* Thu Nov 16 2017 Adam Williamson <awilliam@redhat.com> - 0.6.2-3
- Use and require Google's 'brotli', not brotlipy's 'brotli' (wat)
- Require python(3)-blinker, as raven[flask] requires it

* Thu Nov 16 2017 Adam Williamson <awilliam@redhat.com> - 0.6.2-2
- Drop flask-limiter requirement (which broke the whole thing...)

* Fri Oct 20 2017 Adam Williamson <awilliam@redhat.com> - 0.6.2-1
- Update to 0.6.2

* Wed Aug 30 2017 Adam Williamson <awilliam@redhat.com> - 0.6.1-1
- Update to 0.6.1
- Remove EL 6 compatibility bits (probably won't ever build on EL 6)
- Remove apparently useless upstream requirement for flask-common

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

* Wed May 31 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.5.0-6
- Cleanups in spec
- Remove useless (and broken) requires on python3-pkgversion-macros

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

* Tue Jan 10 2017 Adam Williamson <awilliam@redhat.com> - 0.5.0-4
- Conditionalize argparse dependency as it disappeared from Rawhide

* Wed Dec 21 2016 Adam Williamson <awilliam@redhat.com> - 0.5.0-3
- properly own all directories
- fix the mode of a template (doesn't need to be executable)

* Wed Dec 21 2016 Adam Williamson <awilliam@redhat.com> - 0.5.0-2
- add missing runtime deps to python3 package
- add comment explaining use of LANG

* Wed Dec 21 2016 Adam Williamson <awilliam@redhat.com> - 0.5.0-1
- initial package

## END: Generated by rpmautospec