%global module cornice
%{!?py2ver: %global py2ver %(%{__python2} -c "import sys ; print(sys.version[:3])")}
%{!?py3ver: %global py3ver %(%{__python3} -c "import sys ; print(sys.version[:3])")}
%if 0%{?fedora}
%global with_python3 1
%else
# EL doesn't have Python 3
%global with_python3 0
%endif
%if 0%{?rhel} || 0%{?rhel} < 7
# EL 6 doesn't have this macro
%global __python2 %{__python}
%global python2_sitelib %{python_sitelib}
%endif
%global desc Helpers to build & document Web Services with Pyramid.
Name: python-cornice
Summary: Define Web Services in Pyramid
Version: 1.1.0
Release: 6%{?dist}
BuildArch: noarch
License: MPLv2.0
URL: https://pypi.python.org/pypi/cornice
Source0: https://pypi.python.org/packages/source/c/%{module}/%{module}-%{version}.tar.gz
# This file is missing from the tarball
# https://github.com/mozilla-services/cornice/pull/240
Source1: spore_validation.rx
# https://github.com/Cornices/cornice.ext.sphinx/pull/5
Patch0: 0000-New-setting-in-latest-docutils.patch
# https://github.com/Cornices/cornice.ext.sphinx/pull/9
Patch1: 0001-Initialize-the-ref_context-as-a-dictionary.patch
BuildRequires: python-pyramid
BuildRequires: python-rxjson
BuildRequires: python-venusian
BuildRequires: python-webtest
BuildRequires: python2-colander
BuildRequires: python2-coverage
BuildRequires: python2-devel
BuildRequires: python2-docutils
BuildRequires: python2-mock
BuildRequires: python2-nose
BuildRequires: python2-setuptools
BuildRequires: python2-simplejson
BuildRequires: python2-sphinx
%if %{with_python3}
BuildRequires: python3-colander
BuildRequires: python3-coverage
BuildRequires: python3-devel
BuildRequires: python3-docutils
BuildRequires: python3-mock
BuildRequires: python3-nose
BuildRequires: python3-pyramid
BuildRequires: python3-rxjson
BuildRequires: python3-setuptools
BuildRequires: python3-simplejson
BuildRequires: python3-sphinx
BuildRequires: python3-venusian
BuildRequires: python3-webtest
%endif
%description
%{desc}
%package -n python2-cornice
Summary: %{summary}
Requires: python-pyramid
Requires: python-venusian
Requires: python2-colander
Requires: python2-docutils
Requires: python2-simplejson
%{?python_provide:%python_provide python2-%{module}}
%description -n python2-cornice
%{desc}
%package -n python2-cornice-sphinx
Summary: Generate documentation for Web Services
Requires: python2-cornice = %{version}-%{release}
Requires: python2-sphinx
%{?python_provide:%python_provide python2-cornice-sphinx}
%description -n python2-cornice-sphinx
Generate documentation for Web Services.
%if %{with_python3}
%package -n python3-cornice
Summary: %{summary}
Requires: python3-colander
Requires: python3-docutils
Requires: python3-pyramid
Requires: python3-simplejson
Requires: python3-venusian
%{?python_provide:%python_provide python3-%{module}}
%description -n python3-cornice
%{desc}
%package -n python3-cornice-sphinx
Summary: Generate documentation for Web Services
Requires: python3-cornice = %{version}-%{release}
Requires: python3-sphinx
%{?python_provide:%python_provide python3-cornice-sphinx}
%description -n python3-cornice-sphinx
Generate documentation for Web Services.
%endif
%prep
%setup -q -n %{module}-%{version}
%patch0 -p1
%patch1 -p1
# This file is missing from the tarball
# https://github.com/mozilla-services/cornice/pull/240
cp -p %{SOURCE1} ./cornice/tests/ext/
# Kill some rpmlint warnings about the templates being executable but not having shebangs.
chmod a-x cornice/scaffolds/cornice/*tmpl
chmod a-x cornice/scaffolds/cornice/+package+/*tmpl
%if %{with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif
%build
CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build
%if %{with_python3}
pushd %{py3dir}
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
popd
%endif
%install
%if %{with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
popd
%endif
%{__python2} setup.py install --skip-build --root %{buildroot}
%check
nosetests-%{py2ver}
%if %{with_python3}
pushd %{py3dir}
nosetests-%{py3ver}
popd
%endif
%files -n python2-cornice
%license LICENSE
%doc CHANGES.txt CONTRIBUTORS.txt README.rst
%{python2_sitelib}/%{module}*
%exclude %{python2_sitelib}/%{module}/ext/sphinxext*
%files -n python2-cornice-sphinx
%doc README.rst
%{python2_sitelib}/%{module}/ext/sphinxext*
%if %{with_python3}
%files -n python3-cornice
%license LICENSE
%doc CHANGES.txt CONTRIBUTORS.txt README.rst
%{python3_sitelib}/%{module}*
%exclude %{python3_sitelib}/%{module}/ext/sphinxext*
%exclude %{python3_sitelib}/%{module}/ext/__pycache__/sphinxext*
%files -n python3-cornice-sphinx
%doc README.rst
%{python3_sitelib}/%{module}/ext/sphinxext*
%{python3_sitelib}/%{module}/ext/__pycache__/sphinxext*
%endif
%changelog
* Wed Jul 05 2017 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.1.0-6
- Use python2- requires where appropriate.
* Wed Jul 05 2017 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.1.0-5
- Provide python2- subpackages.
- Use the license macro.
- Reorganize requirements, and sort them alphabetically.
- Remove the execute bit from some templates.
* Tue Mar 07 2017 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.1.0-4
- Apply two patches to allow autodoc generation to work again (#1430185, #1430186).
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.0-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Wed Jan 13 2016 Luke Macken <lmacken@redhat.com> - 1.1.0-1
- Update to 1.1.0
- Get the test suite running again with nose
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.0-3
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Fri Jun 05 2015 Luke Macken <lmacken@redhat.com> - 1.0.0-1
- Update to 1.0.0
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.16.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Sun Jun 01 2014 Mathieu Bridon <bochecha@fedoraproject.org> - 0.16.2-1
- Initial package for Fedora.