File python3-Django.spec of Package python3-Django

#
# spec file for package python3-Django
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           python3-Django
Version:        1.8.4
Release:        0
Summary:        A high-level Python Web framework
License:        BSD-3-Clause
Group:          Development/Languages/Python
Url:            http://www.djangoproject.com
Source:         https://www.djangoproject.com/m/releases/1.8/Django-%{version}.tar.gz
Source1:        https://www.djangoproject.com/m/pgp/Django-%{version}.checksum.txt
Source99:       python3-Django-rpmlintrc
BuildRequires:  fdupes
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Requires:       python3-Pillow
Requires:       python3-xml
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       python3-django = %{version}
Obsoletes:      python3-django < %{version}
Provides:       python3-South = %{version}
Obsoletes:      python3-South < %{version}
BuildArch:      noarch

%description
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

%prep
%setup -q -n Django-%{version}
sed -i "s|\(django/bin/django-admin.py\)|\1-%{py3_ver}|" setup.py
mv django/bin/django-admin.py{,-%{py3_ver}}

%build
python3 setup.py build

%install
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
install -D -m 0644 extras/django_bash_completion %{buildroot}%{_sysconfdir}/bash_completion.d/django_bash_completion-%{py3_ver}.sh

mv %{buildroot}/%{_bindir}/django-admin{,-%{py3_ver}}

mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/django-admin.py
ln -sf %{_sysconfdir}/alternatives/django-admin.py %{buildroot}/%{_bindir}/django-admin.py
touch %{buildroot}%{_sysconfdir}/alternatives/django-admin
ln -sf %{_sysconfdir}/alternatives/django-admin %{buildroot}/%{_bindir}/django-admin
touch %{buildroot}%{_sysconfdir}/alternatives/django_bash_completion.sh
ln -sf %{_sysconfdir}/alternatives/django_bash_completion.sh %{buildroot}%{_sysconfdir}/bash_completion.d/django_bash_completion.sh

%fdupes %{buildroot}%{python3_sitelib}
# Deduplicating files can generate a RPMLINT warning for pyc mtime
cd %{buildroot}%{python3_sitelib}
python3 -m compileall -d %{python3_sitelib} django/conf/locale/

%post
update-alternatives \
    --install %{_bindir}/django-admin.py django-admin.py %{_bindir}/django-admin.py-%{py3_ver} 30 \
    --slave %{_bindir}/django-admin django-admin %{_bindir}/django-admin-%{py3_ver} \
    --slave %{_sysconfdir}/bash_completion.d/django_bash_completion.sh django_bash_completion.sh %{_sysconfdir}/bash_completion.d/django_bash_completion-%{py3_ver}.sh

%preun
if [ $1 -eq 0 ] ; then
    update-alternatives --remove django-admin.py %{_bindir}/django-admin.py-%{py3_ver}
fi

%files
%defattr(-,root,root,-)
%doc AUTHORS LICENSE README.rst
%{_bindir}/django-admin
%{_bindir}/django-admin-%{py3_ver}
%{_bindir}/django-admin.py
%{_bindir}/django-admin.py-%{py3_ver}
%ghost %{_sysconfdir}/alternatives/django-admin
%ghost %{_sysconfdir}/alternatives/django-admin.py
%{python3_sitelib}/django
%{python3_sitelib}/Django-%{version}-py%{py3_ver}.egg-info
%{_sysconfdir}/bash_completion.d/django_bash_completion.sh
%{_sysconfdir}/bash_completion.d/django_bash_completion-%{py3_ver}.sh
%ghost %{_sysconfdir}/alternatives/django_bash_completion.sh

%changelog
openSUSE Build Service is sponsored by