Blob Blame History Raw
# Conditional for release and snapshot builds. Uncomment for release-builds.
#global rel_build 1

# Setup _pkgdocdir if not defined already.
%{!?_pkgdocdir:%global _pkgdocdir	%{_docdir}/%{name}-%{version}}
%{!?_py3docdir:%global _py3docdir	%{_docdir}/python3-%{pypi_name}-%{version}}

# Settings used for build from snapshots.
%{!?rel_build:%global commit		ab2dc2db9db979816a4a7c4fd269ad2f27ef2d0b}
%{!?rel_build:%global commit_date	20150104}
%{!?rel_build:%global shortcommit	%(c=%{commit};echo ${c:0:7})}
%{!?rel_build:%global gitver		git%{commit_date}-%{shortcommit}}
%{!?rel_build:%global gitrel		.git%{commit_date}.%{shortcommit}}

# Proper naming for the tarball from github.
%global gittar %{name}-%{version}%{!?rel_build:-%{gitver}}.tar.gz

# Upstream name
%global pypi_name django-angular

# Do we build a Python3-version?
%if 0%{?fedora} >= 13 || 0%{?rhel} >= 8
%global with_python3 1
%endif # 0%%{?fedora} >= 13 || 0%%{?rhel} >= 8

Name:			python-%{pypi_name}
Version:		0.7.10
Release:		2%{?gitrel}%{?dist}
Summary:		Classes and utility functions to integrate AngularJS with Django

License:		MIT
URL:			https://github.com/jrief/%{pypi_name}
# Sources for release-builds.
%{?rel_build:Source0:	%{url}/archive/%{version}.tar.gz#/%{gittar}}
# Sources for snapshot-builds.
%{!?rel_build:Source0:	%{url}/archive/%{commit}.tar.gz#/%{gittar}}

BuildArch:		noarch

BuildRequires:		python2-devel
BuildRequires:		python-setuptools

Requires:		python-six
Requires:		python-django

%description
Django-Angular is a collection of utilities, which aim to ease the
integration of Django with AngularJS by providing reusable components.


%package doc
Summary:		Documentation-files for %{name}

BuildRequires:		dos2unix
BuildRequires:		python-sphinx

%description doc
This package contains the documentation-files for %{name}.


%if 0%{?with_python3}
%package -n python3-%{pypi_name}
Summary:		Classes and utility functions to integrate AngularJS with Django

BuildRequires:		python3-devel
BuildRequires:		python3-setuptools

Requires:		python3-six
Requires:		python3-django

%description -n python3-%{pypi_name}
Django-Angular is a collection of utilities, which aim to ease the
integration of Django with AngularJS by providing reusable components.


%package -n python3-%{pypi_name}-doc
Summary:		Documentation-files for python3-%{pypi_name}

BuildRequires:		dos2unix
BuildRequires:		python3-sphinx

%description -n python3-%{pypi_name}-doc
This package contains the documentation-files for python3-%{pypi_name}.
%endif # 0%%{?with_python3}


%prep
%setup -qn %{pypi_name}-%{?rel_build:%{version}}%{!?rel_build:%{commit}}

# Remove bundled egg-info and unneded files.
%{__rm} -rf *.egg-info examples/.coveragerc

%if 0%{?with_python3}
# Prepare sources for Python3-build.
%{__rm} -rf %{py3dir}
%{__mkdir} -p %{py3dir}
%{__cp} -a . %{py3dir}
%{__sed} -i -e 's!sphinx-build!&-%{python3_version}!' %{py3dir}/docs/Makefile

# Fix hashbangs.
for _file in $(%{__grep} -Rle '^#![ \t]*/usr/bin/env[ \t]*python' %{py3dir})
do
  %{__sed} -e 's~^#![ \t]*/usr/bin/env[ \t]*python.*$~#!%{__python3}~'	\
	< ${_file} > ${_file}.new
  /bin/touch -r ${_file} ${_file}.new
  %{__mv} -f ${_file}.new ${_file}
done
%endif # 0%%{?with_python3}

# Fix hashbangs.
for _file in $(%{__grep} -Rle '^#![ \t]*/usr/bin/env[ \t]*python' .)
do
  %{__sed} -e 's~^#![ \t]*/usr/bin/env[ \t]*python.*$~#!%{__python2}~'	\
	< ${_file} > ${_file}.new
  /bin/touch -r ${_file} ${_file}.new
  %{__mv} -f ${_file}.new ${_file}
done


%build
%{__python2} setup.py build

# Documentation
pushd docs
%{__make} html
%{__rm} -f _build/html/{.buildinfo,objects.inv}
%{_bindir}/find _build/html -type f -print0 |				\
	%{_bindir}/xargs -0 %{_bindir}/dos2unix -k -o -s
popd

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build

# Documentation
pushd docs
%{__make} html
%{__rm} -f _build/html/{.buildinfo,objects.inv}
%{_bindir}/find _build/html -type f -print0 |				\
	%{_bindir}/xargs -0 %{_bindir}/dos2unix -k -o -s
popd
popd
%endif # 0%%{?with_python3}


%install
%{__python2} setup.py install --skip-build --root %{buildroot}

# Documentation
%{__mkdir} -p %{buildroot}%{?_pkgdocdir}
%{__cp} -a CONTRIBUTIONS.md LICENSE.txt README.md			\
		docs/_build/html client examples			\
		%{buildroot}%{?_pkgdocdir}

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py  install --skip-build --root %{buildroot}

# Documentation
%{__mkdir} -p %{buildroot}%{?_py3docdir}
%{__cp} -a CONTRIBUTIONS.md LICENSE.txt README.md			\
		docs/_build/html client examples			\
		%{buildroot}%{?_py3docdir}
popd
%endif # 0%%{?with_python3}


%check
# noop

%if 0%{?with_python3}
# Final clean-up.
%{__rm} -rf %{py3dir}
%endif # 0%%{?with_python3}


%files
%doc %dir %{?_pkgdocdir}
%doc %{?_pkgdocdir}/LICENSE.txt
%{python2_sitelib}/djangular
%{python2_sitelib}/django_angular-%{version}-py%{python2_version}.egg-info

%files doc
%doc %{?_pkgdocdir}

%if 0%{?with_python3}
%files -n python3-%{pypi_name}
%doc %dir %{?_py3docdir}
%doc %{?_py3docdir}/LICENSE.txt
%{python3_sitelib}/djangular
%{python3_sitelib}/django_angular-%{version}-py%{python3_version}.egg-info

%files -n python3-%{pypi_name}-doc
%doc %{?_py3docdir}
%endif # 0%%{?with_python3}


%changelog
* Thu Jan 15 2015 Björn Esser <bjoern.esser@gmail.com> - 0.7.10-2.git20150104.ab2dc2d
- updated to latest post-release-snapshot

* Thu Jan 15 2015 Björn Esser <bjoern.esser@gmail.com> - 0.7.10-1
- new upstream release 0.7.10
- added sphinx-documentation
- added Python3-build
- several improvements to spec-file

* Thu Jan 15 2015 Björn Esser <bjoern.esser@gmail.com> - 0.7.1-3
- initial import (#1182533)

* Mon May 26 2014 Matthias Runge <mrunge@redhat.com> - 0.7.1-2
- require python-django

* Tue May 20 2014 Matthias Runge <mrunge@redhat.com> - 0.7.1-1
- Initial package.