Blob Blame History Raw
# Python 3 only for Fedora for now.
%if 0%{?fedora} > 12
%global with_python3 1
%endif

%global srcname mimerender

Name:           python-%{srcname}
Version:        0.5.5
Release:        8%{?dist}
Summary:        RESTful HTTP Content Negotiation for Flask, Bottle, etc.

License:        MIT
URL:            http://pypi.python.org/pypi/%{srcname}
Source0:        http://pypi.python.org/packages/source/m/%{srcname}/%{srcname}-%{version}.tar.gz
# https://github.com/martinblech/mimerender/issues/29
Source1:        LICENSE.mimerender

BuildArch:      noarch
BuildRequires:  python2-devel
BuildRequires:  python2-mimeparse
# Needed for EL 7, package does not provide python2-setuptools
BuildRequires:  python2-setuptools
# For tests
# Needs to be fixed to provide python2-unittest2
BuildRequires:  python2-unittest2
%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-mimeparse
BuildRequires:  python3-setuptools
BuildRequires:  python3-unittest2
%endif # if with_python3

%description
mimerender provides a decorator that wraps a HTTP request handler to select
the correct render function for a given HTTP Accept header. It uses mimeparse
to parse the accept string and select the best available representation.
Supports Flask, Bottle, web.py and webapp2 out of the box, and it’s easy to
add support for other frameworks.


%package -n python2-%{srcname}
Summary:        %{summary}
%{?python_provide:%python_provide python2-%{srcname}}
Requires:       python2-mimeparse
# Note: mimerender has subclasses of MimeRenderBase for web.py, Flask,
# Bottle, and webapp2. When you import 'mimerender', the subclass for
# each framework you have installed will be defined; if the framework
# isn't installed, the subclass for it is skipped (they're all in try/
# except blocks). So if you have python2-flask installed you'll get
# the FlaskMimeRender class, if you python2-bottle installed you'll
# get BottleMimeRender, and so on. This relationship is not expressed
# through dependencies as it doesn't seem to the packager that such
# dependencies would actually aid in any real-world use of mimeparse;
# if you want to use it in code you've probably already picked a web
# framework, and if it's just being pulled in as a dependency of some
# other package, *that* package will express the appropriate deps on
# the web framework.
#
# Also note that *executing* mimerender.py requires the unittest or
# unittest2 module. All this does is run the test suite (as used in
# check, below). There is no Requires: for this, because it's not
# the expected use of the package, in all normal cases it will be
# used by importing the module.

%description -n python2-%{srcname}
mimerender provides a decorator that wraps a HTTP request handler to select
the correct render function for a given HTTP Accept header. It uses mimeparse
to parse the accept string and select the best available representation.
Supports Flask, Bottle, web.py and webapp2 out of the box, and it’s easy to
add support for other frameworks. This is the Python 2 build of mimerender.


%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{srcname}}
Requires:       python3-mimeparse
# The note about support for web frameworks above applies to the py3
# package too, of course, except that you need python3-bottle to get
# BottleMimeRender, python3-flask to get FlaskMimeRender, etc. when
# using python3-mimerender.

%description -n python3-%{srcname}
mimerender provides a decorator that wraps a HTTP request handler to select
the correct render function for a given HTTP Accept header. It uses mimeparse
to parse the accept string and select the best available representation.
Supports Flask, Bottle, web.py and webapp2 out of the box, and it’s easy to
add support for other frameworks. This is the Python 3 build of mimerender.
%endif # if with_python3


%prep
%autosetup -n %{srcname}-%{version}
cp %{SOURCE1} ./LICENSE

%build
%py2_build
%if 0%{?with_python3}
%py3_build
%endif # if with_python3

%install
%py2_install
%if 0%{?with_python3}
%py3_install
%endif # if with_python3

%check
%{__python2} src/mimerender.py
%if 0%{?with_python3}
# There seems to be some kind of intermittent bug which causes the test
# suite to fail on py3 sometimes. It seems to fail with pypy too (in
# upstream's travis):
# https://github.com/martinblech/mimerender/issues/31
# Disabling the test suite for now.
#{__python3} src/mimerender.py
%endif # if with_python3

%files -n python2-%{srcname}
%{!?_licensedir:%global license %doc}
%license LICENSE
%{python2_sitelib}/%{srcname}*

%if 0%{?with_python3}
%files -n python3-%{srcname}
%license LICENSE
%{python3_sitelib}/%{srcname}*
%{python3_sitelib}/__pycache__/%{srcname}*
%endif # if with_python3

%changelog
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.5-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Jan 25 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.5.5-7
- Update Python 2 dependency declarations to new packaging standards
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

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

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

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.5.5-4
- Rebuild for Python 3.6

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5.5-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jan 20 2016 Adam Williamson <awilliam@redhat.com> - 0.5.5-1
- initial package (based on skeleton from Python guidelines)