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-*
# blinker is required by raven[flask], but python-raven package does
# not depend on it, so we require it here
%global t_requires python-brotli python-flask python-markupsafe python-decorator python-itsdangerous python-blinker python-raven python-six python2-werkzeug
%global t3_requires python3-blinker python3-brotli python%{python3_pkgversion}-flask python%{python3_pkgversion}-markupsafe python%{python3_pkgversion}-decorator python%{python3_pkgversion}-itsdangerous python3-raven python%{python3_pkgversion}-six python3-werkzeug

Name:           python-%{modname}
Version:        0.7.0
Release:        3%{?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
# Use the Google 'brotli' module, not the useless(?) 'brotlipy' one
# Not upstreaming this till I understand why the hell brotlipy exists
Patch0:         0001-Use-Google-s-brotli-module-not-the-brotlipy-one.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
* 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