dfc41d0
%global pypi_name django-tastypie
dfc41d0
%global docdir %{_docdir}/%{name}-%{fullver}
dfc41d0
dfc41d0
%global majorver 0.9.12
29a920c
%global release 1
dfc41d0
# comment this out to get back to normal versioning
dfc41d0
%global fullver %{majorver}%{?preminorver:-%{preminorver}}
dfc41d0
dfc41d0
Name:           python-%{pypi_name}
dfc41d0
Version:        %{majorver}
dfc41d0
Release:        %{?preminorver:0.}%{release}%{?preminorver:.%{preminorver}}%{?dist}
9d10047
Summary:        A flexible and capable API layer for Django
9d10047
9d10047
Group:          Development/Languages
9d10047
License:        BSD
dfc41d0
URL:            https://github.com/toastdriven/django-tastypie/
dfc41d0
# Only for snapshots:
dfc41d0
# git clone https://github.com/toastdriven/django-tastypie.git
dfc41d0
# mv django-tastypie django-tastypie-0.9.12-alpha
dfc41d0
# tar czf django-tastypie-0.9.12-alpha.tar.gz django-tastypie-0.9.12-alpha
29a920c
#Source0:        %{pypi_name}-%{fullver}.tar.gz
dfc41d0
dfc41d0
# Only for non-snapshot versions:
29a920c
Source0:        http://pypi.python.org/packages/source/d/%%{pypi_name}/%%{pypi_name}-%%{version}.tar.gz
9d10047
# to get tests:
9d10047
# git clone https://github.com/toastdriven/django-tastypie.git && cd django-tastypie
dfc41d0
# git checkout v0.9.12
dfc41d0
# tar -czf django-tastypie-0.9.12-tests.tgz tests/
29a920c
Source1:        %%{pypi_name}-%%{version}-tests.tgz
9d10047
9d10047
BuildArch:      noarch
dfc41d0
# Let's keep Requires and BuildRequires sorted alphabetically
9d10047
BuildRequires:  python2-devel
dfc41d0
%if 0%{?rhel}
dfc41d0
BuildRequires:  python-dateutil15
dfc41d0
%else
9d10047
BuildRequires:  python-dateutil >= 1.5
9d10047
BuildRequires:  python-dateutil < 2.0
dfc41d0
%endif
dfc41d0
%if 0%{?fedora} >= 18
dfc41d0
BuildRequires:  python-django >= 1.2.0
dfc41d0
%else
9d10047
BuildRequires:  Django >= 1.2.0
dfc41d0
%endif
dfc41d0
BuildRequires:  python-lxml
dfc41d0
BuildRequires:  python-mimeparse >= 0.1.3
dfc41d0
BuildRequires:  python-setuptools
dfc41d0
BuildRequires:  python-sphinx
dfc41d0
BuildRequires:  PyYAML
dfc41d0
dfc41d0
%if 0%{?rhel}
dfc41d0
Requires:       python-dateutil15
dfc41d0
# also require setuptools to be able to use 'require' function from pkg_resources module
dfc41d0
Requires:       python-setuptools
dfc41d0
%else
9d10047
Requires:       python-dateutil >= 1.5
9d10047
Requires:       python-dateutil < 2.0
dfc41d0
%endif
dfc41d0
%if 0%{?fedora} >= 18
dfc41d0
Requires:       python-django >= 1.2.0
dfc41d0
%else
9d10047
Requires:       Django >= 1.2.0
dfc41d0
%endif
dfc41d0
Requires:       python-mimeparse >= 0.1.3
9d10047
dfc41d0
Provides:       %{pypi_name} = %{version}-%{release}
dfc41d0
Obsoletes:      %{pypi_name} < 0.9.11-3 
9d10047
9d10047
%description
9d10047
Tastypie is an webservice API framework for Django. It provides a convenient, 
9d10047
yet powerful and highly customizable, abstraction for creating REST-style 
9d10047
interfaces.
9d10047
9d10047
%package doc
9d10047
Summary: Documentation for %{name}
9d10047
Group: Documentation
9d10047
9d10047
Requires: %{name} = %{version}-%{release}
9d10047
9d10047
%description doc
9d10047
This package contains documentation for %{name}.
9d10047
9d10047
9d10047
%prep 
dfc41d0
%setup -q -n django-tastypie-%{fullver}
9d10047
rm -rf *egg-info
dfc41d0
%{!?preminorver:tar xzf %{SOURCE1}}
9d10047
sed -i 's|django-admin.py|django-admin|' tests/run_all_tests.sh
dfc41d0
# (re)generate the documentation
dfc41d0
sphinx-build docs docs/_build/html
dfc41d0
dfc41d0
# if on RHEL, using dateutils15, we need to alter __init__.py to load them properly
dfc41d0
%if 0%{?rhel}
dfc41d0
cat << 'EOF' >> tastypie/__init__.py
dfc41d0
from pkg_resources import require
dfc41d0
require('python-dateutil')
dfc41d0
EOF
dfc41d0
%endif
9d10047
9d10047
%build
9d10047
%{__python} setup.py build
9d10047
9d10047
%install
9d10047
%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
9d10047
mkdir -p $RPM_BUILD_ROOT%{docdir}
9d10047
cp -p LICENSE README.rst AUTHORS -t $RPM_BUILD_ROOT%{docdir}
dfc41d0
cp -pr docs/_build/html -t $RPM_BUILD_ROOT%{docdir}
9d10047
9d10047
%check
9d10047
# note: the oauth tests will work once the proper module gets into rawhide
9d10047
# from the authors documentation it is now not very clear if it is
9d10047
# django-oauth or django-oauth-provider or django-oauth-plus
9d10047
# anyway, it is not a hard requirement
dfc41d0
# also, the gis tests need a running postresql server, so they are skipped
9d10047
pushd tests
dfc41d0
# handle building on hosts with bad DNS
dfc41d0
find -type f -name '*.py' -print | xargs sed -i 's|localhost|127.0.0.1|'
9d10047
./run_all_tests.sh
9d10047
popd
9d10047
 
9d10047
%files
9d10047
%doc README.rst AUTHORS LICENSE
9d10047
%dir %{python_sitelib}/tastypie
9d10047
%{python_sitelib}/django_tastypie*
9d10047
%{python_sitelib}/tastypie/*
9d10047
9d10047
%files doc
9d10047
%doc %{docdir}
dfc41d0
%exclude %{docdir}/html/.*
9d10047
9d10047
%changelog
29a920c
* Mon Mar 25 2013 Cédric OLIVIER <cedric.olivier@free.fr> 0.9.12-1
29a920c
- Updated to upstream 0.9.12
29a920c
4d466b0
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.12-0.2.alpha
4d466b0
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
4d466b0
dfc41d0
* Tue Aug 14 2012 Bohuslav Kabrda <bkabrda@redhat.com> - 0.9.12-0.1.alpha
dfc41d0
- Updated to upstream version 0.9.12-alpha.
dfc41d0
- Adapted the specfile to prerelease versioning.
dfc41d0
- Add some BuildRequires, so that more tests are run (these
dfc41d0
are soft requirements, so they aren't in Requires)
dfc41d0
- Fixed URL to point to upstream, not PyPI.
dfc41d0
- Made the spec compatible with EPEL6.
dfc41d0
440f44c
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.11-5
440f44c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
440f44c
9d10047
* Sun Mar 18 2012 Cédric OLIVIER <cedric.olivier@free.fr> 0.9.11-4
9d10047
- Bugfix in obsoletes
9d10047
9d10047
* Sun Mar 18 2012 Cédric OLIVIER <cedric.olivier@free.fr> 0.9.11-3
9d10047
- Removing bundled .egg-info during prep
9d10047
9d10047
* Sat Mar 17 2012 Cédric OLIVIER <cedric.olivier@free.fr> 0.9.11-2
9d10047
- Adding missing buildrequires
9d10047
- Adding info about renaming django-tastypie
9d10047
- Adding check section
9d10047
- Adding documentation subpackage
9d10047
9d10047
* Wed Mar 02 2012 Cédric OLIVIER <cedric.olivier@free.fr> 0.9.11-1
9d10047
- Initial version of the package