File python-Pillow.spec of Package python-Pillow

#
# spec file for package python-Pillow
#
# 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/
#


Name:           python-Pillow
Version:        2.8.1
Release:        0
Summary:        Python Imaging Library (Fork)
License:        HPND
Group:          Development/Languages/Python
Url:            http://python-imaging.github.io/
Source:         https://pypi.python.org/packages/source/P/Pillow/Pillow-%{version}.tar.gz
Source2:        test_images_01.tar.gz
Source3:        test_images_02.tar.gz
Patch1:         fix-textsize-equal.patch
Patch2:         big-endian.patch
# PATCH-FIX-UPSTREAM 0003-Memory-error-in-Storage.patch -- https://github.com/python-pillow/Pillow/commit/5d8a0be45aad78c5a22c8d099118ee26ef8144af
# also includes one hunk from https://github.com/python-pillow/Pillow/commit/52d60cd09688ff54aa707ccc5c8c41865c32954f#diff-7e3bc1c431db9d44de31c360569407f9R401
Patch3:         0003-Memory-error-in-Storage.patch
# PATCH-FIX-UPSTREAM 0004-Fixed-j2k-integer-overflow-error-on-encode.patch -- https://github.com/python-pillow/Pillow/commit/a1f244343df389cf15cdfff80327594821097295
Patch4:         0004-Fixed-j2k-integer-overflow-error-on-encode.patch
Patch5:         CVE-2016-9189.patch
Patch6:         CVE-2016-2533.patch
Patch7:         CVE-2016-4009.patch
# PATCH-FIX-UPSTREAM: 0008-Corrected-negative-seeks.patch
# CVE-2019-16865: backport of upstream fix from v6.2.0
#   https://github.com/python-pillow/Pillow/pull/4101.patch
Patch8:         0008-Corrected-negative-seeks.patch
# PATCH-FIX-UPSTREAM: 0009-Make-Image.crop-an-immediate-operation.patch
#   Fix for https://github.com/python-pillow/Pillow/issues/2402 required by Patch12
#   backport from v3.4.0
#   https://github.com/python-pillow/Pillow/pull/2138.patch
Patch9:         0009-Make-Image.crop-an-immediate-operation.patch
# PATCH-FIX-UPSTREAM: 0010-Crop-decompression.patch
#   Fix for https://github.com/python-pillow/Pillow/issues/2402 required by Patch12
#   backport from v4.2.0
#   https://github.com/python-pillow/Pillow/pull/2410.patch
Patch10:        0010-Crop-decompression.patch
# PATCH-FIX-UPSTREAM: 0011-Added-DecompressionBombError.patch
#   Added a DecompressionBombError for if the requested size is 2*Image.MAX_PIXELS
#   Without that, decompression bomb tests were just throwing warnings, not exceptions
#   backport from v5.0.0
#   https://github.com/python-pillow/Pillow/pull/2583.patch
Patch11:        0011-Added-DecompressionBombError.patch
# PATCH-FIX-UPSTREAM: 0012-Added-decompression-bomb-checks.patch
# CVE-2019-16865: backport of upstream fix from v6.2.0
#   https://github.com/python-pillow/Pillow/pull/4102.patch
Patch12:        0012-Added-decompression-bomb-checks.patch
# PATCH-FIX-UPSTREAM: 0013-Raise-error-if-dimension-is-a-string.patch
# CVE-2019-16865: backport of upstream fix from v6.2.0
#   https://github.com/python-pillow/Pillow/pull/4103.patch
Patch13:        0013-Raise-error-if-dimension-is-a-string.patch
# PATCH-FIX-UPSTREAM: 0014-Catch-buffer-overruns.patch
# CVE-2019-16865: backport of upstream fix from v6.2.0
#   https://github.com/python-pillow/Pillow/pull/4104.patch
Patch14:        0014-Catch-buffer-overruns.patch
# PATCH-FIX-UPSTREAM: 0015-Catch-PCX-P-mode-buffer-overrun.patch
# CVE-2020-5312: backport of upstream fix from v6.2.2
#   https://github.com/python-pillow/Pillow/commit/93b22b846e0269ee9594ff71a72bec02d2bea8fd.patch
Patch15:        0015-Catch-PCX-P-mode-buffer-overrun.patch
# PATCH-FIX-UPSTREAM: 0016-Ensure-previous-FLI-frame-is-loaded.patch
# Fix for https://github.com/python-pillow/Pillow/issues/2649 which uncovers CVE-2020-5313
#   backport from v5.4.0
#   https://github.com/python-pillow/Pillow/pull/3478.patch
Patch16:        0016-Ensure-previous-FLI-frame-is-loaded.patch
# PATCH-FIX-UPSTREAM: 0017-Catch-FLI-buffer-overrun.patch
# CVE-2020-5313: backport of upstream fix from v6.2.2
#   https://github.com/python-pillow/Pillow/commit/a09acd0decd8a87ccce939d5ff65dab59e7d365b.patch
Patch17:        0017-Catch-FLI-buffer-overrun.patch
# PATCH-FIX-UPSTREAM: 0018-Invalid-number-of-bands-in-FPX-image.patch
# CVE-2019-19911: backport of upstream fix from v6.2.2
#   https://github.com/python-pillow/Pillow/commit/774e53bb132461d8d5ebefec1162e29ec0ebc63d.patch
Patch18:        0018-Invalid-number-of-bands-in-FPX-image.patch
# PATCH-FIX-UPSTREAM: 0019-FLI-overflow-error-fix-and-testcase.patch
# CVE-2016-0775: backport of upstream fix from v3.2.0
#   https://github.com/python-pillow/Pillow/commit/893a40850c2d5da41537958e40569c029a6e127b.patch
Patch19:        0019-FLI-overflow-error-fix-and-testcase.patch
# PATCH-FIX-UPSTREAM: 0020-Fix-OOB-reads-in-FLI-decoding.patch
# CVE-2020-10177: backport of upstream fix from v7.1.0
#   https://github.com/python-pillow/Pillow/pull/4503.patch
Patch20:        0020-Fix-OOB-reads-in-FLI-decoding.patch
# PATCH-FIX-UPSTREAM: 0021-Fix-bounds-overflow-in-JPEG-2000-decoding.patch
# CVE-2020-10994: backport of upstream fix from v7.1.0
#   https://github.com/python-pillow/Pillow/pull/4505.patch
Patch21:        0021-Fix-bounds-overflow-in-JPEG-2000-decoding.patch
# PATCH-FIX-UPSTREAM: 0022-Fix-bounds-overflow-in-PCX-decoding.patch
# CVE-2020-10378: backport of upstream fix from v7.1.0
#   https://github.com/python-pillow/Pillow/pull/4506.patch
Patch22:        0022-Fix-bounds-overflow-in-PCX-decoding.patch
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  python-tk
BuildRequires:  tix
BuildRequires:  tk-devel
BuildRequires:  unzip
%if 0%{?suse_version} > 1210
BuildRequires:  libjpeg8-devel
BuildRequires:  liblcms2-devel
BuildRequires:  libwebp-devel
%else
BuildRequires:  python-unittest2
%endif
%if 0%{?suse_version} > 1315
BuildRequires:  openjpeg2-devel
%endif
BuildRequires:  freetype2-devel
BuildRequires:  libtiff-devel
BuildRequires:  python-nose
BuildRequires:  zlib-devel
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%endif
# Pillow is a friendly PIL fork which we package as 'imaging', the latter isn't obsolete though:
Conflicts:      python-imaging < %{version}
# NOTE(saschpe): python-imaging should have never provided this and I'm a bit relucatant do it either.
# http://en.opensuse.org/openSUSE:Upgrade_dependencies_explanation#Replace_a_package_by_another_with_the_same_functionality
# ALSO NOTE (frispete): without providing python-imaging, all packages requiring it will break
Provides:       python-imaging = %{version}

Obsoletes:      python-imaging-sane
Provides:       python-imaging-sane

%description
Pillow is the "friendly" PIL fork by Alex Clark and Contributors. PIL is the
Python Imaging Library by Fredrik Lundh and Contributors.

%package tk
Summary:        Python Imaging Library (Fork) - Tcl/Tk Module
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
# NOTE: We don't need to conflict with python-imaging here,
# because this package depends on python-Pillow, which already conflicts with python-imaging,
# so this cannot be installed alongside python-imaging
# And we cannot conflict with python-imaging directly, since python-Pillow provides python-imaging
# Just in case, conflict with python-imaging-tk in case it is ever implemented.
Obsoletes:      python-imaging-tk
Provides:       python-imaging-tk

%description tk
Pillow is the "friendly" PIL fork by Alex Clark and Contributors. PIL is the
Python Imaging Library by Fredrik Lundh and Contributors.

#NOTE(saschpe): No 'sane' subpackage like "python-imaging", that stuff
# would belong into python-pysane, if anybody would care :-)

%prep
%setup -q -n Pillow-%{version} -a 2
%setup -q -T -D -n Pillow-%{version} -a 3
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1

%build
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for p in pilconvert pildriver pilfile pilfont pilprint ; do
  mv %{buildroot}%{_bindir}/$p.py %{buildroot}%{_bindir}/$p-%{py_ver}
  ln -s %{_bindir}/$p-%{py_ver} %{buildroot}%{_bindir}/$p
  ln -s %{_bindir}/$p-%{py_ver} %{buildroot}%{_sysconfdir}/alternatives/$p
done
# add missing path
echo "PIL" > %{buildroot}%{python_sitearch}/PIL.pth

%check
PYTHONPATH=%{buildroot}/%{python_sitearch} python selftest.py --installed
PYTHONPATH=%{buildroot}/%{python_sitearch} python test-installed.py

%post
update-alternatives \
    --install %{_bindir}/pilconvert pilconvert %{_bindir}/pilconvert-%{py_ver} 20 \
    --slave %{_bindir}/pildriver pildriver %{_bindir}/pildriver-%{py_ver} \
    --slave %{_bindir}/pilfile pilfile %{_bindir}/pilfile-%{py_ver} \
    --slave %{_bindir}/pilfont pilfont %{_bindir}/pilfont-%{py_ver} \
    --slave %{_bindir}/pilprint pilprint %{_bindir}/pilprint-%{py_ver}

%preun
if [ $1 -eq 0 ] ; then
    update-alternatives --remove pilconvert %{_bindir}/pilconvert-%{py_ver}
fi

%files
%defattr(-,root,root,-)
%doc CHANGES.rst README.rst LICENSE
%ghost %{_bindir}/pilconvert
%{_bindir}/pilconvert-%{py_ver}
%ghost %{_bindir}/pildriver
%{_bindir}/pildriver-%{py_ver}
%ghost %{_bindir}/pilfile
%{_bindir}/pilfile-%{py_ver}
%ghost %{_bindir}/pilfont
%{_bindir}/pilfont-%{py_ver}
%ghost %{_bindir}/pilprint
%{_bindir}/pilprint-%{py_ver}
%{python_sitearch}/PIL
%{python_sitearch}/PIL.pth
%{python_sitearch}/Pillow-%{version}-py%{py_ver}.egg-info
%exclude %{python_sitearch}/PIL/ImageTk*
%exclude %{python_sitearch}/PIL/_imagingtk*
%ghost %{_sysconfdir}/alternatives/pilconvert
%ghost %{_sysconfdir}/alternatives/pildriver
%ghost %{_sysconfdir}/alternatives/pilfile
%ghost %{_sysconfdir}/alternatives/pilfont
%ghost %{_sysconfdir}/alternatives/pilprint

%files tk
%defattr(-,root,root,-)
%{python_sitearch}/PIL/ImageTk*
%{python_sitearch}/PIL/_imagingtk*

%changelog
openSUSE Build Service is sponsored by