2019-09-22 16:48:49 +02:00
|
|
|
from toolchain import CythonRecipe, shprint
|
2015-02-25 18:51:03 +01:00
|
|
|
from os.path import join
|
2019-09-22 16:48:49 +02:00
|
|
|
from os import chdir, listdir
|
|
|
|
import sh
|
2015-02-09 11:58:44 +01:00
|
|
|
|
|
|
|
|
2015-02-25 18:51:03 +01:00
|
|
|
class KivyRecipe(CythonRecipe):
|
2019-09-22 16:48:49 +02:00
|
|
|
version = "1.11.0"
|
2015-02-09 11:58:44 +01:00
|
|
|
url = "https://github.com/kivy/kivy/archive/{version}.zip"
|
2015-02-09 23:34:02 +01:00
|
|
|
library = "libkivy.a"
|
2018-11-02 11:44:25 +01:00
|
|
|
depends = ["sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios",
|
|
|
|
"pyobjus", "python"]
|
2015-02-23 11:34:36 +01:00
|
|
|
pbx_frameworks = ["OpenGLES", "Accelerate"]
|
2015-02-25 13:37:52 +01:00
|
|
|
pre_build_ext = True
|
2015-02-09 11:58:44 +01:00
|
|
|
|
2015-02-25 13:37:52 +01:00
|
|
|
def get_recipe_env(self, arch):
|
|
|
|
env = super(KivyRecipe, self).get_recipe_env(arch)
|
|
|
|
env["KIVY_SDL2_PATH"] = ":".join([
|
2015-02-13 18:39:34 +01:00
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2"),
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2_image"),
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2_ttf"),
|
|
|
|
join(self.ctx.dist_dir, "include", "common", "sdl2_mixer")])
|
2015-02-25 13:37:52 +01:00
|
|
|
return env
|
2015-02-09 23:34:02 +01:00
|
|
|
|
|
|
|
def build_arch(self, arch):
|
|
|
|
self._patch_setup()
|
2015-02-25 13:37:52 +01:00
|
|
|
super(KivyRecipe, self).build_arch(arch)
|
2015-02-09 23:34:02 +01:00
|
|
|
|
|
|
|
def _patch_setup(self):
|
|
|
|
# patch setup to remove some functionnalities
|
|
|
|
pyconfig = join(self.build_dir, "setup.py")
|
|
|
|
def _remove_line(lines, pattern):
|
|
|
|
for line in lines[:]:
|
|
|
|
if pattern in line:
|
|
|
|
lines.remove(line)
|
|
|
|
with open(pyconfig) as fd:
|
|
|
|
lines = fd.readlines()
|
|
|
|
_remove_line(lines, "flags['libraries'] = ['GLESv2']")
|
2015-02-12 00:53:22 +01:00
|
|
|
#_remove_line(lines, "c_options['use_sdl'] = True")
|
2017-04-29 17:51:42 +02:00
|
|
|
with open(pyconfig, "w") as fd:
|
2015-02-09 23:34:02 +01:00
|
|
|
fd.writelines(lines)
|
|
|
|
|
2019-09-22 16:48:49 +02:00
|
|
|
def install_python_package(self, name=None, env=None, is_dir=True):
|
|
|
|
"""
|
|
|
|
Automate the installation of a Python package into the target
|
|
|
|
site-packages.
|
|
|
|
"""
|
|
|
|
# arch = self.filtered_archs[0]
|
|
|
|
for arch in self.filtered_archs:
|
|
|
|
if name is None:
|
|
|
|
name = self.name
|
|
|
|
if env is None:
|
|
|
|
env = self.get_recipe_env(arch)
|
|
|
|
print("Install {} into the site-packages".format(name))
|
|
|
|
build_dir = self.get_build_dir(arch.arch)
|
|
|
|
chdir(build_dir)
|
|
|
|
|
|
|
|
hostpython = sh.Command(self.ctx.hostpython)
|
|
|
|
env["PYTHONPATH"] = self.ctx.site_packages_dir
|
|
|
|
shprint(
|
|
|
|
hostpython,
|
|
|
|
"setup.py",
|
|
|
|
"bdist_egg",
|
|
|
|
"--plat-name={}".format(arch.arch),
|
|
|
|
_env=env,
|
|
|
|
)
|
|
|
|
for file in listdir("./dist"):
|
|
|
|
if file.endswith(".egg"):
|
|
|
|
egg_name = file
|
|
|
|
shprint(
|
|
|
|
hostpython,
|
|
|
|
"setup.py",
|
|
|
|
"easy_install",
|
|
|
|
"--no-deps",
|
|
|
|
"--install-dir",
|
|
|
|
self.ctx.site_packages_dir,
|
|
|
|
join("dist", egg_name),
|
|
|
|
_env=env,
|
|
|
|
)
|
|
|
|
|
2015-02-09 11:58:44 +01:00
|
|
|
|
|
|
|
recipe = KivyRecipe()
|