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

# Not currently building on EPEL 7 as brotli is not built for it

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

# Enable Python 3 builds for Fedora + EPEL >7
# EPEL 7 is missing Python 3 builds of flask and itsdangerous
%if 0%{?rhel} && 0%{?rhel} < 8
%bcond_with python3
%else
%bcond_without python3
%endif

# Requirements for tests (BuildRequires) and run (Requires)
# EPEL builds do not provide python2-*
%global t_requires python-brotli python-flask python-markupsafe python-decorator python-itsdangerous python-raven python-six
%global t3_requires python3-brotli python%{python3_pkgversion}-flask python%{python3_pkgversion}-markupsafe python%{python3_pkgversion}-decorator python%{python3_pkgversion}-itsdangerous python3-raven python%{python3_pkgversion}-six

Name:           python-%{modname}
Version:        0.6.2
Release:        1%{?dist}
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
# Upstream pulls in flask-common to add response headers, but we don't
# have it packaged yet
# https://github.com/kennethreitz/httpbin/issues/381
Patch0:         0001-Revert-Flask-Common.patch
BuildArch:      noarch


%description
%{desc}

%package -n python2-%{modname}
Summary:        %{summary}
BuildRequires:  python2-devel
BuildRequires:  python2-setuptools
BuildRequires:  %{t_requires}
Requires:       %{t_requires}
%{?python_provide:%python_provide python2-%{modname}}

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

This package provides the Python 2 implementation.

%if %{with python3}
%package -n python%{python3_pkgversion}-%{modname}
Summary:        %{summary}
BuildRequires:  python%{python3_pkgversion}-setuptools
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  %{t3_requires}
Requires:       %{t3_requires}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{modname}}

%description -n python%{python3_pkgversion}-%{modname}
%{desc}

This package provides the Python 3 implementation.

%if 0%{?with_python3_other}
%package -n python%{python3_other_pkgversion}-%{modname}
Summary:        %{summary}
BuildRequires:  python%{python3_other_pkgversion}-setuptools
BuildRequires:  python%{python3_other_pkgversion}-devel
%{?python_provide:%python_provide python%{python3_other_pkgversion}-%{modname}}

%description -n python%{python3_other_pkgversion}-%{modname}
%{desc}

This package provides the Python 3 implementation.
%endif
%endif

#################################################################################
%prep
%autosetup -n %{modname}-%{version} -p1
# no need for this to be executable
chmod ugo-x httpbin/templates/forms-post.html

%build
%py2_build

# use of read() without an explicit codec in setup.py will use 'ascii'
# codec in Fedora build env, which can fail if text has non-ascii chars
%if %{with python3}
LANG=en_US.UTF-8 %py3_build

%if 0%{?with_python3_other}
%py3_other_build
%endif
%endif


%install
%py2_install

# use of read() without an explicit codec in setup.py will use 'ascii'
# codec in Fedora build env, which can fail if text has non-ascii chars
%if %{with python3}
LANG=en_US.UTF-8 %py3_install

%if 0%{?with_python3_other}
LANG=en_US.UTF-8 %py3_other_install
%endif
%endif

#################################################################################
%check
%{__python2} test_httpbin.py
%if %{with python3}
%{__python3} test_httpbin.py
%endif

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

%if %{with python3}
%files -n python%{python3_pkgversion}-%{modname}
%{python3_sitelib}/%{modname}*
%license LICENSE
%doc README.md AUTHORS

%if 0%{?with_python3_other}
%files -n python%{python3_other_pkgversion}-%{modname}
%{python3_other_sitelib}/%{modname}*
%license LICENSE
%doc README.md AUTHORS
%endif
%endif

#################################################################################
%changelog
* 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