forked from kivy/python-for-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
103 lines (84 loc) · 3.72 KB
/
__init__.py
File metadata and controls
103 lines (84 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from os.path import join
import sys
import packaging.version
import sh
from pythonforandroid.recipe import PyProjectRecipe
from pythonforandroid.toolchain import current_directory, shprint
def get_kivy_version(recipe, arch):
with current_directory(join(recipe.get_build_dir(arch.arch), "kivy")):
return shprint(
sh.Command(sys.executable),
"-c",
"import _version; print(_version.__version__)",
)
def is_kivy_affected_by_deadlock_issue(recipe=None, arch=None):
return packaging.version.parse(
str(get_kivy_version(recipe, arch))
) < packaging.version.Version("2.2.0.dev0")
def is_kivy_less_than_3(recipe=None, arch=None):
return packaging.version.parse(
str(get_kivy_version(recipe, arch))
) < packaging.version.Version("3.0.0")
class KivyRecipe(PyProjectRecipe):
version = '2.3.1'
url = 'https://github.com/kivy/kivy/archive/{version}.zip'
name = 'kivy'
depends = [('sdl2', 'sdl3'), 'pyjnius', 'setuptools', 'android']
python_depends = ['certifi', 'chardet', 'idna', 'requests', 'urllib3', 'filetype']
hostpython_prerequisites = ["cython>=0.29.1,<=3.0.12"]
# sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
# See: https://github.com/kivy/kivy/pull/8025
# WARNING: Remove this patch when a new Kivy version is released.
patches = [
("sdl-gl-swapwindow-nogil.patch", is_kivy_affected_by_deadlock_issue),
("use_cython.patch", is_kivy_less_than_3),
"no-ast-str.patch"
]
@property
def need_stl_shared(self):
if "sdl3" in self.ctx.recipe_build_order:
return True
else:
return False
def get_recipe_env(self, arch, **kwargs):
env = super().get_recipe_env(arch, **kwargs)
# Taken from CythonRecipe
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
self.ctx.get_libs_dir(arch.arch) +
' -L{} '.format(self.ctx.libs_dir) +
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
arch.arch)))
env['LDSHARED'] = env['CC'] + ' -shared'
env['LIBLINK'] = 'NOTNONE'
# NDKPLATFORM is our switch for detecting Android platform, so can't be None
env['NDKPLATFORM'] = "NOTNONE"
if not is_kivy_less_than_3(self, arch):
env['KIVY_CROSS_PLATFORM'] = 'android'
if 'sdl2' in self.ctx.recipe_build_order:
env['USE_SDL2'] = '1'
env['KIVY_SPLIT_EXAMPLES'] = '1'
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
sdl2_image_recipe = self.get_recipe('sdl2_image', self.ctx)
env['KIVY_SDL2_PATH'] = ':'.join([
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
*sdl2_image_recipe.get_include_dirs(arch),
*sdl2_mixer_recipe.get_include_dirs(arch),
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
])
if "sdl3" in self.ctx.recipe_build_order:
sdl3_mixer_recipe = self.get_recipe("sdl3_mixer", self.ctx)
sdl3_image_recipe = self.get_recipe("sdl3_image", self.ctx)
sdl3_ttf_recipe = self.get_recipe("sdl3_ttf", self.ctx)
sdl3_recipe = self.get_recipe("sdl3", self.ctx)
env["USE_SDL3"] = "1"
env["KIVY_SPLIT_EXAMPLES"] = "1"
env["KIVY_SDL3_PATH"] = ":".join(
[
*sdl3_mixer_recipe.get_include_dirs(arch),
*sdl3_image_recipe.get_include_dirs(arch),
*sdl3_ttf_recipe.get_include_dirs(arch),
*sdl3_recipe.get_include_dirs(arch),
]
)
return env
recipe = KivyRecipe()