1
- import glob
2
- from os .path import basename , exists , join
1
+ from os .path import join
3
2
import sys
4
3
import packaging .version
5
4
6
5
import sh
7
- from pythonforandroid .recipe import CythonRecipe
6
+ from pythonforandroid .recipe import PyProjectRecipe
8
7
from pythonforandroid .toolchain import current_directory , shprint
9
8
10
9
@@ -21,7 +20,7 @@ def is_kivy_affected_by_deadlock_issue(recipe=None, arch=None):
21
20
) < packaging .version .Version ("2.2.0.dev0" )
22
21
23
22
24
- class KivyRecipe (CythonRecipe ):
23
+ class KivyRecipe (PyProjectRecipe ):
25
24
version = '2.3.1'
26
25
url = 'https://github.com/kivy/kivy/archive/{version}.zip'
27
26
name = 'kivy'
@@ -33,34 +32,20 @@ class KivyRecipe(CythonRecipe):
33
32
# sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
34
33
# See: https://github.com/kivy/kivy/pull/8025
35
34
# WARNING: Remove this patch when a new Kivy version is released.
36
- patches = [("sdl-gl-swapwindow-nogil.patch" , is_kivy_affected_by_deadlock_issue )]
35
+ patches = [("sdl-gl-swapwindow-nogil.patch" , is_kivy_affected_by_deadlock_issue ), "use_cython.patch" ]
37
36
38
- def cythonize_build (self , env , build_dir = '.' ):
39
- super ().cythonize_build ( env , build_dir = build_dir )
37
+ def get_recipe_env (self , arch , ** kwargs ):
38
+ env = super ().get_recipe_env ( arch , ** kwargs )
40
39
41
- if not exists (join (build_dir , 'kivy' , 'include' )):
42
- return
40
+ # Taken from CythonRecipe
41
+ env ['LDFLAGS' ] = env ['LDFLAGS' ] + ' -L{} ' .format (
42
+ self .ctx .get_libs_dir (arch .arch ) +
43
+ ' -L{} ' .format (self .ctx .libs_dir ) +
44
+ ' -L{}' .format (join (self .ctx .bootstrap .build_dir , 'obj' , 'local' ,
45
+ arch .arch )))
46
+ env ['LDSHARED' ] = env ['CC' ] + ' -shared'
47
+ env ['LIBLINK' ] = 'NOTNONE'
43
48
44
- # If kivy is new enough to use the include dir, copy it
45
- # manually to the right location as we bypass this stage of
46
- # the build
47
- with current_directory (build_dir ):
48
- build_libs_dirs = glob .glob (join ('build' , 'lib.*' ))
49
-
50
- for dirn in build_libs_dirs :
51
- shprint (sh .cp , '-r' , join ('kivy' , 'include' ),
52
- join (dirn , 'kivy' ))
53
-
54
- def cythonize_file (self , env , build_dir , filename ):
55
- # We can ignore a few files that aren't important to the
56
- # android build, and may not work on Android anyway
57
- do_not_cythonize = ['window_x11.pyx' , 'camera_avfoundation.pyx' , 'img_imageio.pyx' , 'egl_angle_metal.pyx' ]
58
- if basename (filename ) in do_not_cythonize :
59
- return
60
- super ().cythonize_file (env , build_dir , filename )
61
-
62
- def get_recipe_env (self , arch ):
63
- env = super ().get_recipe_env (arch )
64
49
# NDKPLATFORM is our switch for detecting Android platform, so can't be None
65
50
env ['NDKPLATFORM' ] = "NOTNONE"
66
51
if 'sdl2' in self .ctx .recipe_build_order :
0 commit comments