Add patches to fix build on bigendian

This commit is contained in:
Sandro Mani 2013-04-08 01:09:51 +02:00
parent c216b5f3a7
commit da3613d089
3 changed files with 1859 additions and 3 deletions

View File

@ -17,7 +17,7 @@
Name: python-pillow Name: python-pillow
Version: 2.0.0 Version: 2.0.0
Release: 4%{?snap}%{?dist} Release: 5%{?snap}%{?dist}
Summary: Python 2 image processing library Summary: Python 2 image processing library
# License: see http://www.pythonware.com/products/pil/license.htm # License: see http://www.pythonware.com/products/pil/license.htm
@ -30,6 +30,10 @@ Source0: https://github.com/python-imaging/Pillow/tarball/%{commit}/pytho
# Add s390* and ppc* archs # Add s390* and ppc* archs
Patch0: python-pillow-archs.patch Patch0: python-pillow-archs.patch
# Fix quantization code
Patch1: python-pillow_quantization.patch
# Fix tests which are hardcoded for little-endian CPUs
Patch2: python-pillow_endianness.patch
BuildRequires: python2-devel BuildRequires: python2-devel
BuildRequires: python-setuptools BuildRequires: python-setuptools
@ -169,6 +173,8 @@ Tk interface for %{name3}.
%prep %prep
%setup -q -n python-imaging-Pillow-%{shortcommit} %setup -q -n python-imaging-Pillow-%{shortcommit}
%patch0 -p1 -b .archs %patch0 -p1 -b .archs
%patch1 -p1 -b .quant
%patch2 -p1 -b .endian
%if %{with_python3} %if %{with_python3}
# Create Python 3 source tree # Create Python 3 source tree
@ -237,7 +243,6 @@ rm -rf $RPM_BUILD_ROOT%{_bindir}
%check %check
%ifnarch ppc %{power64} s390 s390x
# Check Python 2 modules # Check Python 2 modules
ln -s $PWD/Images $RPM_BUILD_ROOT%{python_sitearch}/Images ln -s $PWD/Images $RPM_BUILD_ROOT%{python_sitearch}/Images
ln -s $PWD/Tests $RPM_BUILD_ROOT%{python_sitearch}/Tests ln -s $PWD/Tests $RPM_BUILD_ROOT%{python_sitearch}/Tests
@ -265,7 +270,6 @@ rm $RPM_BUILD_ROOT%{python3_sitearch}/Tests
rm $RPM_BUILD_ROOT%{python3_sitearch}/selftest.py* rm $RPM_BUILD_ROOT%{python3_sitearch}/selftest.py*
popd popd
%endif %endif
%endif
%files %files
@ -317,6 +321,9 @@ popd
%endif %endif
%changelog %changelog
* Mon Apr 08 2013 Sandro Mani <manisandro@gmail.com> - 2.0.0-5.git93a488e
- Reenable tests on bigendian, add patches for #928927
* Sun Apr 07 2013 Sandro Mani <manisandro@gmail.com> - 2.0.0-4.git93a488e * Sun Apr 07 2013 Sandro Mani <manisandro@gmail.com> - 2.0.0-4.git93a488e
- Update to latest git - Update to latest git
- disable tests on bigendian (PPC*, S390*) until rhbz#928927 is fixed - disable tests on bigendian (PPC*, S390*) until rhbz#928927 is fixed

View File

@ -0,0 +1,58 @@
diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py
index c2e8590..351621d 100644
--- a/Tests/test_image_array.py
+++ b/Tests/test_image_array.py
@@ -10,8 +10,8 @@ def test(mode):
return ai["shape"], ai["typestr"], len(ai["data"])
# assert_equal(test("1"), ((100, 128), '|b1', 1600))
assert_equal(test("L"), ((100, 128), '|u1', 12800))
- assert_equal(test("I"), ((100, 128), '<i4', 51200)) # FIXME: wrong?
- assert_equal(test("F"), ((100, 128), '<f4', 51200)) # FIXME: wrong?
+ assert_equal(test("I"), ((100, 128), Image._ENDIAN + 'i4', 51200)) # FIXME: wrong?
+ assert_equal(test("F"), ((100, 128), Image._ENDIAN + 'f4', 51200)) # FIXME: wrong?
assert_equal(test("RGB"), ((100, 128, 3), '|u1', 38400))
assert_equal(test("RGBA"), ((100, 128, 4), '|u1', 51200))
assert_equal(test("RGBX"), ((100, 128, 4), '|u1', 51200))
diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py
index 5bf622c..b3355b6 100644
--- a/Tests/test_lib_pack.py
+++ b/Tests/test_lib_pack.py
@@ -18,6 +18,8 @@ def pack(mode, rawmode):
else:
return [ord(c) for c in im.tobytes("raw", rawmode)]
+ order = 1 if Image._ENDIAN == '<' else -1
+
assert_equal(pack("1", "1"), [128])
assert_equal(pack("1", "1;I"), [0])
assert_equal(pack("1", "1;R"), [1])
@@ -25,9 +27,9 @@ def pack(mode, rawmode):
assert_equal(pack("L", "L"), [1])
- assert_equal(pack("I", "I"), [1, 0, 0, 0])
+ assert_equal(pack("I", "I"), [1, 0, 0, 0][::order])
- assert_equal(pack("F", "F"), [0, 0, 128, 63])
+ assert_equal(pack("F", "F"), [0, 0, 128, 63][::order])
assert_equal(pack("LA", "LA"), [1, 2])
diff --git a/Tests/test_mode_i16.py b/Tests/test_mode_i16.py
index 584bdd9..4c17985 100644
--- a/Tests/test_mode_i16.py
+++ b/Tests/test_mode_i16.py
@@ -84,10 +84,12 @@ def test_tobytes():
def tobytes(mode):
return Image.new(mode, (1, 1), 1).tobytes()
+ order = 1 if Image._ENDIAN == '<' else -1
+
assert_equal(tobytes("L"), b"\x01")
assert_equal(tobytes("I;16"), b"\x01\x00")
assert_equal(tobytes("I;16B"), b"\x00\x01")
- assert_equal(tobytes("I"), b"\x01\x00\x00\x00")
+ assert_equal(tobytes("I"), b"\x01\x00\x00\x00"[::order])
def test_convert():

File diff suppressed because it is too large Load Diff