File python-Django.spec of Package python-Django.18568

#
# spec file for package python-Django
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
# Selenium and memcached are not operational
%bcond_with selenium
%bcond_with memcached
Name:           python-Django
# We want support LTS versions of Django -  numbered 2.2 -> 3.2 -> 4.2 etc
Version:        2.2.28
Release:        0
Summary:        A high-level Python Web framework
License:        BSD-3-Clause
URL:            https://www.djangoproject.com
Source:         https://www.djangoproject.com/m/releases/2.2/Django-%{version}.tar.gz
Source1:        https://www.djangoproject.com/m/pgp/Django-%{version}.checksum.txt
Source2:        %{name}.keyring
Source99:       python-Django-rpmlintrc
Patch0:         i18n_test.patch
Patch1:         test_clear_site_cache-sort.patch
Patch2:         fix-selenium-test.patch
Patch3:         fix-cve-2022-36359.patch
Patch4:         fix-cve-2022-41323.patch
Patch5:         test_custom_fields.patch
Patch6:         fix-cve-2023-23969.patch
# PATCH-FIX-UPSTREAM CVE-2023-24580-DOS_file_upload.patch bsc#1208082 mcepl@suse.com
# prevent DOS in file uploads
Patch7:         CVE-2023-24580-DOS_file_upload.patch
# PATCH-FIX-UPSTREAM fix-cve-2023-36053.patch bsc#1212742
Patch8:         fix-cve-2023-36053.patch
# PATCH-FIX-UPSTREAM CVE-2023-43665.patch bsc#1215978
Patch9:         CVE-2023-43665.patch
# PATCH-FIX-UPSTREAM
Patch10:        fix_test_lazy_addresses.patch
# PATCH-FIX-UPSTREAM CVE-2024-27351.patch bsc#1220358
Patch11:        CVE-2024-27351.patch
# PATCH-FIX-UPSTREAM CVE-2024-38875.patch bsc#1227590
Patch12:        CVE-2024-38875.patch
# PATCH-FIX-UPSTREAM CVE-2024-39329.patch bsc#1227593
Patch13:        CVE-2024-39329.patch
# PATCH-FIX-UPSTREAM CVE-2024-39330.patch bsc#1227594
Patch14:        CVE-2024-39330.patch
# PATCH-FIX-UPSTREAM CVE-2024-39614.patch bsc#1227595
Patch15:        CVE-2024-39614.patch
# PATCH-FIX-UPSTREAM upstream commits gh#django/django#08c5a78, gh#django/django#4b066bd and gh#django/django#dcd9746 folded together
# gh#django/django#08c5a78 needed for CVE-2024-41989.patch to pass tests, the two followup commits are fixing crashes introduced by it
Patch16:        Decimal.patch
# PATCH-FIX-UPSTREAM CVE-2024-41989.patch bsc#1228629
Patch17:        CVE-2024-41989.patch
# PATCH-FIX-UPSTREAM CVE-2024-41990.patch bsc#1228630
Patch18:        CVE-2024-41990.patch
# PATCH-FIX-UPSTREAM CVE-2024-41991.patch bsc#1228631
Patch19:        CVE-2024-41991.patch
# PATCH-FIX-UPSTREAM CVE-2024-42005.patch bsc#1228632
Patch20:        CVE-2024-42005.patch
# PATCH-FIX-UPSTREAM https://github.com/django/django/commit/8d76443aba863b75ad3b1392ca7e1d59bad84dc4 Changed django.utils.html.escape()/urlize() to use html.escape()/unescape().
# needed for tests in CVE-2024-45230.patch to work
Patch21:        unescape.patch
# PATCH-FIX-UPSTREAM CVE-2024-45230.patch bsc#1229823
Patch22:        CVE-2024-45230.patch
# PATCH-FIX-UPSTREAM CVE-2024-45231.patch bsc#1229824
Patch23:        CVE-2024-45231.patch
BuildRequires:  %{python_module Jinja2 >= 2.9.2}
BuildRequires:  %{python_module Pillow}
BuildRequires:  %{python_module PyYAML}
BuildRequires:  %{python_module argon2-cffi >= 16.1.0}
BuildRequires:  %{python_module base >= 3.5}
BuildRequires:  %{python_module bcrypt}
BuildRequires:  %{python_module docutils}
BuildRequires:  %{python_module geoip2}
BuildRequires:  %{python_module numpy}
BuildRequires:  %{python_module psycopg2}
BuildRequires:  %{python_module pytz}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module sqlparse}
BuildRequires:  %{python_module tblib}
BuildRequires:  %{pythons}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python
Requires:       python-Pillow
Requires:       python-argon2-cffi >= 16.1.0
Requires:       python-pytz
Requires:       python-setuptools
Requires:       python-sqlparse
Requires(post): update-alternatives
Requires(preun): update-alternatives
Recommends:     python-Jinja2 >= 2.9.2
Recommends:     python-PyYAML
Recommends:     python-argon2-cffi >= 16.1.0
Recommends:     python-bcrypt
Recommends:     python-geoip2
Recommends:     python-pylibmc
Recommends:     python-python-memcached >= 1.59
Provides:       python3-django = %{version}
Obsoletes:      python3-django < %{version}
Provides:       python3-South = %{version}
Obsoletes:      python3-South < %{version}
BuildArch:      noarch
%if %{with memcached}
BuildRequires:  %{python_module pylibmc}
BuildRequires:  %{python_module python-memcached >= 1.59}
%endif
%if %{with selenium}
# python-selenium is supported only on the Intel architecture.
# Additionally chromedriver is only available on x86_64.
%ifarch %{ix86} x86_64
BuildRequires:  %{python_module selenium}
BuildRequires:  chromedriver
BuildRequires:  xvfb-run
%endif
%endif
%python_subpackages

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

%prep
# The publisher doesn't sign the source tarball, but a signatures file containing multiple hashes.
# Verify hashes in that file against source tarball.
echo "`grep -e '^[0-9a-f]\{32\}  Django-%{version}.tar.gz' %{SOURCE1} | cut -c1-32`  %{SOURCE0}" | md5sum -c
echo "`grep -e '^[0-9a-f]\{40\}  Django-%{version}.tar.gz' %{SOURCE1} | cut -c1-40`  %{SOURCE0}" | sha1sum -c
echo "`grep -e '^[0-9a-f]\{64\}  Django-%{version}.tar.gz' %{SOURCE1} | cut -c1-64`  %{SOURCE0}" | sha256sum -c

%autosetup -p1 -n Django-%{version}
chmod a-x django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js

%build
%python_build

%install
%python_install

%python_clone -a %{buildroot}%{_bindir}/django-admin.py
%python_clone -a %{buildroot}%{_bindir}/django-admin

%{python_expand install -D -m 0644 extras/django_bash_completion %{buildroot}%%{_datadir}/bash-completion/completions/django_bash_completion-%{$python_bin_suffix}.sh
# Fix wrong-script-interpreter
sed -i "s|^#!%{_bindir}/env python$|#!%{__$python}|" \
  %{buildroot}%{$python_sitelib}/django/bin/django-admin.py \
  %{buildroot}%{$python_sitelib}/django/conf/project_template/manage.py-tpl
%fdupes %{buildroot}%{$python_sitelib}/django/
%fdupes %{buildroot}%{$python_sitelib}/Django-%{version}-py*.egg-info/
}

%check
export LANG=en_US.UTF8
export PYTHONDONTWRITEBYTECODE=1
%if %{with selenium}
export PATH=%{_libdir}/chromium:$PATH
%python_expand PYTHONPATH=%{buildroot}%{$python_sitelib} xvfb-run $python tests/runtests.py -v 2 --selenium=chrome
%else
%python_expand PYTHONPATH=%{buildroot}%{$python_sitelib} $python tests/runtests.py
%endif

%post
%{python_install_alternative django-admin.py django-admin}

%preun
%python_uninstall_alternative django-admin

%files %{python_files}
%doc AUTHORS README.rst
%license LICENSE
%python_alternative %{_bindir}/django-admin
%python_alternative %{_bindir}/django-admin.py
%{_datadir}/bash-completion/completions/django_bash_completion-%{python_bin_suffix}.sh
%{python_sitelib}/django
%{python_sitelib}/Django-%{version}-py*.egg-info

%changelog
openSUSE Build Service is sponsored by