1- import glob
2- from os .path import basename , exists , join
3- import sys
4- import packaging .version
1+ from os .path import join
2+ from pythonforandroid .recipe import PyProjectRecipe
53
6- import sh
7- from pythonforandroid .recipe import CythonRecipe
8- from pythonforandroid .toolchain import current_directory , shprint
94
10-
11- def is_kivy_affected_by_deadlock_issue (recipe = None , arch = None ):
12- with current_directory (join (recipe .get_build_dir (arch .arch ), "kivy" )):
13- kivy_version = shprint (
14- sh .Command (sys .executable ),
15- "-c" ,
16- "import _version; print(_version.__version__)" ,
17- )
18-
19- return packaging .version .parse (
20- str (kivy_version )
21- ) < packaging .version .Version ("2.2.0.dev0" )
22-
23-
24- class KivyRecipe (CythonRecipe ):
5+ class KivyRecipe (PyProjectRecipe ):
256 version = '2.3.1'
267 url = 'https://github.com/kivy/kivy/archive/{version}.zip'
8+ < << << << HEAD
279 name = 'kivy'
2810
2911 depends = [('sdl2' , 'sdl3' ), 'pyjnius' , 'setuptools' ]
12+ | | | | | | | parent of e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
13+ name = 'kivy'
14+
15+ depends = ['sdl2' , 'pyjnius' , 'setuptools' ]
16+ == == == =
17+ depends = ['sdl2' , 'pyjnius' ]
18+ >> >> >> > e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
3019 python_depends = ['certifi' , 'chardet' , 'idna' , 'requests' , 'urllib3' , 'filetype' ]
20+ < << << << HEAD
3121 hostpython_prerequisites = []
22+ | | | | | | | parent of e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
23+ == == == =
24+ patches = ["use_cython.patch" ]
25+ >> >> >> > e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
3226
27+ < << << << HEAD
3328 # sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
3429 # See: https://github.com/kivy/kivy/pull/8025
3530 # WARNING: Remove this patch when a new Kivy version is released.
@@ -61,11 +56,49 @@ def cythonize_file(self, env, build_dir, filename):
6156
6257 def get_recipe_env (self , arch ):
6358 env = super ().get_recipe_env (arch )
59+ | | | | | | | parent of e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
60+ # sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
61+ # See: https://github.com/kivy/kivy/pull/8025
62+ # WARNING: Remove this patch when a new Kivy version is released.
63+ patches = [("sdl-gl-swapwindow-nogil.patch" , is_kivy_affected_by_deadlock_issue )]
64+
65+ def cythonize_build (self , env , build_dir = '.' ):
66+ super ().cythonize_build (env , build_dir = build_dir )
67+
68+ if not exists (join (build_dir , 'kivy' , 'include' )):
69+ return
70+
71+ # If kivy is new enough to use the include dir, copy it
72+ # manually to the right location as we bypass this stage of
73+ # the build
74+ with current_directory (build_dir ):
75+ build_libs_dirs = glob .glob (join ('build' , 'lib.*' ))
76+
77+ for dirn in build_libs_dirs :
78+ shprint (sh .cp , '-r' , join ('kivy' , 'include' ),
79+ join (dirn , 'kivy' ))
80+
81+ def cythonize_file (self , env , build_dir , filename ):
82+ # We can ignore a few files that aren't important to the
83+ # android build, and may not work on Android anyway
84+ do_not_cythonize = ['window_x11.pyx' , ]
85+ if basename (filename ) in do_not_cythonize :
86+ return
87+ super ().cythonize_file (env , build_dir , filename )
88+
89+ def get_recipe_env (self , arch ):
90+ env = super ().get_recipe_env (arch )
91+ == == == =
92+ def get_recipe_env (self , arch , ** kwargs ):
93+ env = super ().get_recipe_env (arch , ** kwargs )
94+ >> >> >> > e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
6495 # NDKPLATFORM is our switch for detecting Android platform, so can't be None
6596 env ['NDKPLATFORM' ] = "NOTNONE"
97+ env ['LIBLINK' ] = "NOTNONE"
6698 if 'sdl2' in self .ctx .recipe_build_order :
6799 env ['USE_SDL2' ] = '1'
68100 env ['KIVY_SPLIT_EXAMPLES' ] = '1'
101+ sdl_recipe = self .get_recipe ("sdl2" , self .ctx )
69102 sdl2_mixer_recipe = self .get_recipe ('sdl2_mixer' , self .ctx )
70103 sdl2_image_recipe = self .get_recipe ('sdl2_image' , self .ctx )
71104 env ['KIVY_SDL2_PATH' ] = ':' .join ([
@@ -74,6 +107,7 @@ def get_recipe_env(self, arch):
74107 * sdl2_mixer_recipe .get_include_dirs (arch ),
75108 join (self .ctx .bootstrap .build_dir , 'jni' , 'SDL2_ttf' ),
76109 ])
110+ < << << << HEAD
77111 if "sdl3" in self .ctx .recipe_build_order :
78112 sdl3_mixer_recipe = self .get_recipe ("sdl3_mixer" , self .ctx )
79113 sdl3_image_recipe = self .get_recipe ("sdl3_image" , self .ctx )
@@ -90,6 +124,11 @@ def get_recipe_env(self, arch):
90124 ]
91125 )
92126
127+ | | | | | | | parent of e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
128+
129+ == == == =
130+ env ["LDFLAGS" ] += " -L" + join (sdl_recipe .get_build_dir (arch .arch ), "../.." , "libs" , arch .arch )
131+ >> >> >> > e3538b5 (`kivy` and `pyjnius` : switch to `PyProjectRecipe` )
93132 return env
94133
95134
0 commit comments