Skip to content

Commit 5dc17e1

Browse files
authored
Merge pull request kivy#3022 from T-Dynamos/pillow-update
pillow: update to `10.3.0`
2 parents 9e467a5 + 3d69b69 commit 5dc17e1

File tree

3 files changed

+89
-234
lines changed

3 files changed

+89
-234
lines changed

pythonforandroid/recipes/Pillow/__init__.py

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from os.path import join
22

3-
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
3+
from pythonforandroid.recipe import PyProjectRecipe
44

55

6-
class PillowRecipe(CompiledComponentsPythonRecipe):
6+
class PillowRecipe(PyProjectRecipe):
77
"""
88
A recipe for Pillow (previously known as Pil).
99
@@ -23,67 +23,42 @@ class PillowRecipe(CompiledComponentsPythonRecipe):
2323
- libwebp: library to encode and decode images in WebP format.
2424
"""
2525

26-
version = '8.4.0'
26+
version = '10.3.0'
2727
url = 'https://github.com/python-pillow/Pillow/archive/{version}.tar.gz'
2828
site_packages_name = 'PIL'
29+
patches = ["setup.py.patch"]
2930
depends = ['png', 'jpeg', 'freetype', 'setuptools']
3031
opt_depends = ['libwebp']
31-
patches = [join('patches', 'fix-setup.patch')]
3232

33-
call_hostpython_via_targetpython = False
34-
35-
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
36-
env = super().get_recipe_env(arch, with_flags_in_cc)
37-
38-
png = self.get_recipe('png', self.ctx)
39-
png_lib_dir = join(png.get_build_dir(arch.arch), '.libs')
40-
png_inc_dir = png.get_build_dir(arch)
33+
def get_recipe_env(self, arch, **kwargs):
34+
env = super().get_recipe_env(arch, **kwargs)
4135

4236
jpeg = self.get_recipe('jpeg', self.ctx)
4337
jpeg_inc_dir = jpeg_lib_dir = jpeg.get_build_dir(arch.arch)
38+
env["JPEG_ROOT"] = "{}:{}".format(jpeg_lib_dir, jpeg_inc_dir)
4439

4540
freetype = self.get_recipe('freetype', self.ctx)
4641
free_lib_dir = join(freetype.get_build_dir(arch.arch), 'objs', '.libs')
4742
free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include')
43+
env["FREETYPE_ROOT"] = "{}:{}".format(free_lib_dir, free_inc_dir)
4844

4945
# harfbuzz is a direct dependency of freetype and we need the proper
5046
# flags to successfully build the Pillow recipe, so we add them here.
5147
harfbuzz = self.get_recipe('harfbuzz', self.ctx)
5248
harf_lib_dir = join(harfbuzz.get_build_dir(arch.arch), 'src', '.libs')
5349
harf_inc_dir = harfbuzz.get_build_dir(arch.arch)
50+
env["HARFBUZZ_ROOT"] = "{}:{}".format(harf_lib_dir, harf_inc_dir)
51+
52+
env["ZLIB_ROOT"] = f"{arch.ndk_lib_dir_versioned}:{self.ctx.ndk.sysroot_include_dir}"
5453

5554
# libwebp is an optional dependency, so we add the
5655
# flags if we have it in our `ctx.recipe_build_order`
57-
build_with_webp_support = 'libwebp' in self.ctx.recipe_build_order
58-
if build_with_webp_support:
56+
if 'libwebp' in self.ctx.recipe_build_order:
5957
webp = self.get_recipe('libwebp', self.ctx)
6058
webp_install = join(
6159
webp.get_build_dir(arch.arch), 'installation'
6260
)
63-
64-
# Add libraries includes to CFLAGS
65-
cflags = f' -I{png_inc_dir}'
66-
cflags += f' -I{harf_inc_dir} -I{join(harf_inc_dir, "src")}'
67-
cflags += f' -I{free_inc_dir}'
68-
cflags += f' -I{jpeg_inc_dir}'
69-
if build_with_webp_support:
70-
cflags += f' -I{join(webp_install, "include")}'
71-
cflags += f' -I{self.ctx.ndk.sysroot_include_dir}'
72-
73-
# Link the basic Pillow libraries...no need to add webp's libraries
74-
# since it seems that the linkage is properly made without it :)
75-
env['LIBS'] = ' -lpng -lfreetype -lharfbuzz -ljpeg -lturbojpeg -lm'
76-
77-
# Add libraries locations to LDFLAGS
78-
env['LDFLAGS'] += f' -L{png_lib_dir}'
79-
env['LDFLAGS'] += f' -L{free_lib_dir}'
80-
env['LDFLAGS'] += f' -L{harf_lib_dir}'
81-
env['LDFLAGS'] += f' -L{jpeg_lib_dir}'
82-
if build_with_webp_support:
83-
env['LDFLAGS'] += f' -L{join(webp_install, "lib")}'
84-
env['LDFLAGS'] += f' -L{arch.ndk_lib_dir_versioned}'
85-
if cflags not in env['CFLAGS']:
86-
env['CFLAGS'] += cflags + " -lm"
61+
env["WEBP_ROOT"] = f"{join(webp_install, 'lib')}:{join(webp_install, 'include')}"
8762
return env
8863

8964

pythonforandroid/recipes/Pillow/patches/fix-setup.patch

Lines changed: 0 additions & 196 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
--- Pillow/setup.py 2024-05-24 19:35:08.270160608 +0530
2+
+++ Pillow.mod/setup.py 2024-05-24 22:07:52.741495666 +0530
3+
@@ -39,6 +39,7 @@
4+
LCMS_ROOT = None
5+
TIFF_ROOT = None
6+
ZLIB_ROOT = None
7+
+WEBP_ROOT = None
8+
FUZZING_BUILD = "LIB_FUZZING_ENGINE" in os.environ
9+
10+
if sys.platform == "win32" and sys.version_info >= (3, 13):
11+
@@ -150,6 +151,7 @@
12+
13+
14+
def _find_library_dirs_ldconfig():
15+
+ return []
16+
# Based on ctypes.util from Python 2
17+
18+
ldconfig = "ldconfig" if shutil.which("ldconfig") else "/sbin/ldconfig"
19+
@@ -460,15 +462,16 @@
20+
"HARFBUZZ_ROOT": "harfbuzz",
21+
"FRIBIDI_ROOT": "fribidi",
22+
"LCMS_ROOT": "lcms2",
23+
+ "WEBP_ROOT": "libwebp",
24+
"IMAGEQUANT_ROOT": "libimagequant",
25+
}.items():
26+
root = globals()[root_name]
27+
28+
if root is None and root_name in os.environ:
29+
- prefix = os.environ[root_name]
30+
- root = (os.path.join(prefix, "lib"), os.path.join(prefix, "include"))
31+
+ root = tuple(os.environ[root_name].split(":"))
32+
33+
if root is None and pkg_config:
34+
+ continue
35+
if isinstance(lib_name, tuple):
36+
for lib_name2 in lib_name:
37+
_dbg(f"Looking for `{lib_name2}` using pkg-config.")
38+
@@ -495,14 +498,6 @@
39+
for include_dir in include_root:
40+
_add_directory(include_dirs, include_dir)
41+
42+
- # respect CFLAGS/CPPFLAGS/LDFLAGS
43+
- for k in ("CFLAGS", "CPPFLAGS", "LDFLAGS"):
44+
- if k in os.environ:
45+
- for match in re.finditer(r"-I([^\s]+)", os.environ[k]):
46+
- _add_directory(include_dirs, match.group(1))
47+
- for match in re.finditer(r"-L([^\s]+)", os.environ[k]):
48+
- _add_directory(library_dirs, match.group(1))
49+
-
50+
# include, rpath, if set as environment variables:
51+
for k in ("C_INCLUDE_PATH", "CPATH", "INCLUDE"):
52+
if k in os.environ:
53+
@@ -514,13 +509,10 @@
54+
for d in os.environ[k].split(os.path.pathsep):
55+
_add_directory(library_dirs, d)
56+
57+
- _add_directory(library_dirs, os.path.join(sys.prefix, "lib"))
58+
- _add_directory(include_dirs, os.path.join(sys.prefix, "include"))
59+
-
60+
#
61+
# add platform directories
62+
63+
- if self.disable_platform_guessing:
64+
+ if True:
65+
pass
66+
67+
elif sys.platform == "cygwin":
68+
@@ -614,7 +606,7 @@
69+
# FIXME: check /opt/stuff directories here?
70+
71+
# standard locations
72+
- if not self.disable_platform_guessing:
73+
+ if False: #not self.disable_platform_guessing:
74+
_add_directory(library_dirs, "/usr/local/lib")
75+
_add_directory(include_dirs, "/usr/local/include")
76+

0 commit comments

Comments
 (0)