Blob Blame History Raw
# Not building on EPEL 6 due to incompatibility with Werkzeug < 0.9:
# https://github.com/Runscope/httpbin/issue/317

# 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.

# Requirements for tests (BuildRequires) and run (Requires)
# blinker is required by raven[flask], but python-raven package does
# not depend on it, so we require it here
%global t_requires python3-blinker python3-brotli python3-flask python3-markupsafe python3-decorator python3-itsdangerous python3-raven python3-six python3-werkzeug

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

License:        MIT
URL:            https://github.com/Runscope/httpbin
Source0:        %{url}/archive/v%{version}/%{modname}-%{version}.tar.gz
# 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 on 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.
Patch1:         0001-Use-Google-s-brotli-module-not-the-brotlipy-one.patch

# Drop content length == 0 asserts, to support werkzeug>=0.15.1
# From https://github.com/postmanlabs/httpbin/pull/555
Patch2:         0002-Drop-content-length-0-asserts.patch
# Set Response.autocorrect_location_header = False instead of
# BaseResponse.autocorrect_location_header = False to support
# werkzeug >= 2.0.0
# https://github.com/postmanlabs/httpbin/pull/649
Patch3:         0001-Fix-disabling-of-location-header-autocorrect-for-wer.patch
BuildArch:      noarch


%description
%{desc}

%package -n python3-%{modname}
Summary:        %{summary}
BuildRequires:  python3-setuptools
BuildRequires:  python3-devel
BuildRequires:  %{t_requires}
Requires:       %{t_requires}
%{?python_provide:%python_provide python3-%{modname}}
%if 0%{?obsolete2}
Obsoletes:      python2-%{modname} < %{version}-%{release}
%endif # obsolete2

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

This package provides the Python 3 implementation.

#################################################################################
%prep
%setup -q -n %{modname}-%{version}
%patch1 -p1
# these patches shouldn't be applied on EPEL 7 o 8, where we're using
# ancient werkzeug
%if 0%{?fedora} || 0%{?rhel} > 8
%patch2 -p1
%patch3 -p1
%endif

# no need for this to be executable
chmod ugo-x httpbin/templates/forms-post.html

# this requirement is kinda bogus, it was added in
# https://github.com/postmanlabs/httpbin/commit/75c8317 but all that
# commit really does is drop a test assertion which was no longer true
# with newer werkzeug; the package and tests still actually work fine
# with older werkzeug
sed -i -e 's,werkzeug>=0.14.1,werkzeug,g' setup.py

%build
%py3_build

%install
%py3_install

#################################################################################
%check
%{__python3} test_httpbin.py

#################################################################################
%files -n python3-%{modname}
%{python3_sitelib}/%{modname}*
%license LICENSE
%doc README.md AUTHORS

#################################################################################
%changelog
%autochangelog