1
1
from os .path import join
2
2
3
- from pythonforandroid .recipe import CompiledComponentsPythonRecipe
3
+ from pythonforandroid .recipe import PyProjectRecipe
4
4
5
5
6
- class PillowRecipe (CompiledComponentsPythonRecipe ):
6
+ class PillowRecipe (PyProjectRecipe ):
7
7
"""
8
8
A recipe for Pillow (previously known as Pil).
9
9
@@ -23,67 +23,42 @@ class PillowRecipe(CompiledComponentsPythonRecipe):
23
23
- libwebp: library to encode and decode images in WebP format.
24
24
"""
25
25
26
- version = '8.4 .0'
26
+ version = '10.3 .0'
27
27
url = 'https://github.com/python-pillow/Pillow/archive/{version}.tar.gz'
28
28
site_packages_name = 'PIL'
29
+ patches = ["setup.py.patch" ]
29
30
depends = ['png' , 'jpeg' , 'freetype' , 'setuptools' ]
30
31
opt_depends = ['libwebp' ]
31
- patches = [join ('patches' , 'fix-setup.patch' )]
32
32
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 )
41
35
42
36
jpeg = self .get_recipe ('jpeg' , self .ctx )
43
37
jpeg_inc_dir = jpeg_lib_dir = jpeg .get_build_dir (arch .arch )
38
+ env ["JPEG_ROOT" ] = "{}:{}" .format (jpeg_lib_dir , jpeg_inc_dir )
44
39
45
40
freetype = self .get_recipe ('freetype' , self .ctx )
46
41
free_lib_dir = join (freetype .get_build_dir (arch .arch ), 'objs' , '.libs' )
47
42
free_inc_dir = join (freetype .get_build_dir (arch .arch ), 'include' )
43
+ env ["FREETYPE_ROOT" ] = "{}:{}" .format (free_lib_dir , free_inc_dir )
48
44
49
45
# harfbuzz is a direct dependency of freetype and we need the proper
50
46
# flags to successfully build the Pillow recipe, so we add them here.
51
47
harfbuzz = self .get_recipe ('harfbuzz' , self .ctx )
52
48
harf_lib_dir = join (harfbuzz .get_build_dir (arch .arch ), 'src' , '.libs' )
53
49
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 } "
54
53
55
54
# libwebp is an optional dependency, so we add the
56
55
# 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 :
59
57
webp = self .get_recipe ('libwebp' , self .ctx )
60
58
webp_install = join (
61
59
webp .get_build_dir (arch .arch ), 'installation'
62
60
)
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' )} "
87
62
return env
88
63
89
64
0 commit comments