Skip to content

Commit bced168

Browse files
committed
support for kivy master
1 parent fe5ae5a commit bced168

File tree

5 files changed

+61
-46
lines changed

5 files changed

+61
-46
lines changed

pythonforandroid/archs.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from os import environ
22
from os.path import join
3+
from glob import glob
34
from multiprocessing import cpu_count
45
import shutil
56

67
from pythonforandroid.recipe import Recipe
7-
from pythonforandroid.util import BuildInterruptingException, build_platform
8+
from pythonforandroid.util import BuildInterruptingException
89

910

1011
class Arch:
@@ -212,16 +213,12 @@ def get_env(self, with_flags_in_cc=True):
212213

213214
# Host python (used by some recipes)
214215
hostpython_recipe = Recipe.get_recipe(
215-
'host' + self.ctx.python_recipe.name, self.ctx)
216-
env['BUILDLIB_PATH'] = join(
216+
'hostpython3', self.ctx)
217+
218+
env['BUILDLIB_PATH'] = glob(join(
217219
hostpython_recipe.get_build_dir(self.arch),
218-
'native-build',
219-
'build',
220-
'lib.{}-{}'.format(
221-
build_platform,
222-
self.ctx.python_recipe.major_minor_version_string,
223-
),
224-
)
220+
'native-build', 'build', 'lib*'
221+
))[0]
225222

226223
# for reproducible builds
227224
if 'SOURCE_DATE_EPOCH' in environ:

pythonforandroid/bootstraps/_sdl_common/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from os.path import join
22

33
from pythonforandroid.toolchain import Bootstrap
4+
from pythonforandroid.recipe import Recipe
45
from pythonforandroid.util import ensure_dir
56

67

@@ -14,10 +15,12 @@ def _assemble_distribution_for_arch(self, arch):
1415
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
1516
# Note: SDL bootstrap does not call distribute_aars()
1617

17-
python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle')
18+
python_bundle_dir = join(f"_python_bundle__{arch.arch}", "_python_bundle")
1819
ensure_dir(python_bundle_dir)
19-
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
20-
join(self.dist_dir, python_bundle_dir), arch)
20+
python_recipe = Recipe.get_recipe("python3", self.ctx)
21+
site_packages_dir = python_recipe.create_python_bundle(
22+
join(self.dist_dir, python_bundle_dir), arch
23+
)
2124
if not self.ctx.with_debug_symbols:
2225
self.strip_libraries(arch)
2326
self.fry_eggs(site_packages_dir)

pythonforandroid/distribution.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
debug, info, info_notify, warning, Err_Style, Err_Fore)
77
from pythonforandroid.util import (
88
current_directory, BuildInterruptingException, rmdir)
9+
from pythonforandroid.recipe import Recipe
910

1011

1112
class Distribution:
@@ -256,8 +257,8 @@ def save_info(self, dirn):
256257
'ndk_api': self.ctx.ndk_api,
257258
'use_setup_py': self.ctx.use_setup_py,
258259
'recipes': self.ctx.recipe_build_order + self.ctx.python_modules,
259-
'hostpython': self.ctx.hostpython,
260-
'python_version': self.ctx.python_recipe.major_minor_version_string},
260+
'hostpython': Recipe.get_recipe("hostpython3", self.ctx).python_exe,
261+
'python_version': Recipe.get_recipe("python3", self.ctx).major_minor_version_string},
261262
fileh)
262263

263264

pythonforandroid/recipes/kivy/__init__.py

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,44 @@
77
from pythonforandroid.toolchain import current_directory, shprint
88

99

10-
def is_kivy_affected_by_deadlock_issue(recipe=None, arch=None):
10+
def get_kivy_version(recipe=None, arch=None):
1111
with current_directory(join(recipe.get_build_dir(arch.arch), "kivy")):
1212
kivy_version = shprint(
1313
sh.Command(sys.executable),
1414
"-c",
1515
"import _version; print(_version.__version__)",
1616
)
17+
return str(kivy_version)
18+
19+
20+
def is_kivy_affected_by_deadlock_issue(recipe=None, arch=None):
21+
return packaging.version.parse(
22+
get_kivy_version(recipe, arch)
23+
) < packaging.version.Version("2.2.0.dev0")
24+
1725

18-
return packaging.version.parse(
19-
str(kivy_version)
20-
) < packaging.version.Version("2.2.0.dev0")
26+
def is_kivy_less_than_3(recipe=None, arch=None):
27+
return packaging.version.parse(
28+
get_kivy_version(recipe, arch)
29+
) < packaging.version.Version("3.0.0.dev0")
2130

2231

2332
class KivyRecipe(PyProjectRecipe):
24-
version = '2.3.1'
25-
url = 'https://github.com/kivy/kivy/archive/{version}.zip'
26-
name = 'kivy'
33+
version = "2.3.1"
34+
url = "https://github.com/kivy/kivy/archive/{version}.zip"
35+
name = "kivy"
2736

28-
depends = [('sdl2', 'sdl3'), 'pyjnius', 'setuptools', 'android']
29-
python_depends = ['certifi', 'chardet', 'idna', 'requests', 'urllib3', 'filetype']
37+
depends = [("sdl2", "sdl3"), "pyjnius", "setuptools", "android"]
38+
python_depends = ["certifi", "chardet", "idna", "requests", "urllib3", "filetype"]
3039
hostpython_prerequisites = ["cython>=0.29.1,<=3.0.12"]
3140

3241
# sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
3342
# See: https://github.com/kivy/kivy/pull/8025
3443
# WARNING: Remove this patch when a new Kivy version is released.
3544
patches = [
3645
("sdl-gl-swapwindow-nogil.patch", is_kivy_affected_by_deadlock_issue),
37-
"use_cython.patch",
38-
"no-ast-str.patch"
46+
("use_cython.patch", is_kivy_less_than_3),
47+
"no-ast-str.patch",
3948
]
4049

4150
@property
@@ -49,27 +58,32 @@ def get_recipe_env(self, arch, **kwargs):
4958
env = super().get_recipe_env(arch, **kwargs)
5059

5160
# Taken from CythonRecipe
52-
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
53-
self.ctx.get_libs_dir(arch.arch) +
54-
' -L{} '.format(self.ctx.libs_dir) +
55-
' -L{}'.format(join(self.ctx.bootstrap.build_dir, 'obj', 'local',
56-
arch.arch)))
57-
env['LDSHARED'] = env['CC'] + ' -shared'
58-
env['LIBLINK'] = 'NOTNONE'
61+
env["LDFLAGS"] = env["LDFLAGS"] + " -L{} ".format(
62+
self.ctx.get_libs_dir(arch.arch)
63+
+ " -L{} ".format(self.ctx.libs_dir)
64+
+ " -L{}".format(
65+
join(self.ctx.bootstrap.build_dir, "obj", "local", arch.arch)
66+
)
67+
)
68+
env["LDSHARED"] = env["CC"] + " -shared"
69+
env["LIBLINK"] = "NOTNONE"
70+
env["KIVY_CROSS_PLATFORM"] = "android"
5971

6072
# NDKPLATFORM is our switch for detecting Android platform, so can't be None
61-
env['NDKPLATFORM'] = "NOTNONE"
62-
if 'sdl2' in self.ctx.recipe_build_order:
63-
env['USE_SDL2'] = '1'
64-
env['KIVY_SPLIT_EXAMPLES'] = '1'
65-
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
66-
sdl2_image_recipe = self.get_recipe('sdl2_image', self.ctx)
67-
env['KIVY_SDL2_PATH'] = ':'.join([
68-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
69-
*sdl2_image_recipe.get_include_dirs(arch),
70-
*sdl2_mixer_recipe.get_include_dirs(arch),
71-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
72-
])
73+
env["NDKPLATFORM"] = "NOTNONE"
74+
if "sdl2" in self.ctx.recipe_build_order:
75+
env["USE_SDL2"] = "1"
76+
env["KIVY_SPLIT_EXAMPLES"] = "1"
77+
sdl2_mixer_recipe = self.get_recipe("sdl2_mixer", self.ctx)
78+
sdl2_image_recipe = self.get_recipe("sdl2_image", self.ctx)
79+
env["KIVY_SDL2_PATH"] = ":".join(
80+
[
81+
join(self.ctx.bootstrap.build_dir, "jni", "SDL", "include"),
82+
*sdl2_image_recipe.get_include_dirs(arch),
83+
*sdl2_mixer_recipe.get_include_dirs(arch),
84+
join(self.ctx.bootstrap.build_dir, "jni", "SDL2_ttf"),
85+
]
86+
)
7387
if "sdl3" in self.ctx.recipe_build_order:
7488
sdl3_mixer_recipe = self.get_recipe("sdl3_mixer", self.ctx)
7589
sdl3_image_recipe = self.get_recipe("sdl3_image", self.ctx)

pythonforandroid/recipes/python3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def compile_python_files(self, dir):
392392
python3, and as of Python 3.5, the .pyo filename extension is no
393393
longer used...uses .pyc (https://www.python.org/dev/peps/pep-0488)
394394
'''
395-
args = [self.ctx.hostpython]
395+
args = [Recipe.get_recipe("hostpython3", self.ctx).python_exe]
396396
args += ['-OO', '-m', 'compileall', '-b', '-f', dir]
397397
subprocess.call(args)
398398

0 commit comments

Comments
 (0)