11from 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
0 commit comments