kivy-ios/kivy_ios/recipes/cffi/__init__.py

52 lines
2 KiB
Python
Raw Normal View History

2020-09-25 01:06:37 +02:00
from kivy_ios.toolchain import CythonRecipe, shprint
from os.path import join
import os
import sh
class CffiRecipe(CythonRecipe):
name = "cffi"
2020-09-28 23:29:32 +02:00
version = "1.14.3"
url = "https://pypi.python.org/packages/source/c/cffi/cffi-{version}.tar.gz"
library = "libcffi.a"
2020-09-28 23:29:32 +02:00
depends = ["host_cffi", "libffi", "pycparser"]
cythonize = False
def get_recipe_env(self, arch):
env = super(CffiRecipe, self).get_recipe_env(arch)
env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
env["LDFLAGS"] = " ".join([
env.get('CFLAGS', '')
])
return env
def install(self):
arch = list(self.filtered_archs)[0]
build_dir = self.get_build_dir(arch.arch)
os.chdir(build_dir)
# manually create expected directory in build directory
2020-09-28 23:29:32 +02:00
scripts_dir = join("build", "scripts-3.8")
if not os.path.exists(scripts_dir):
os.makedirs(scripts_dir)
hostpython = sh.Command(self.ctx.hostpython)
build_env = arch.get_env()
2020-09-28 23:29:32 +02:00
dest_dir = join(self.ctx.dist_dir, "root", "python3")
2020-09-25 01:06:37 +02:00
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.8', 'site-packages')
shprint(hostpython, "setup.py", "build_ext", _env=build_env)
shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
2018-06-02 22:17:35 +02:00
# hack: copy _cffi_backend.so from hostpython
2020-09-28 23:29:32 +02:00
so_file = "_cffi_backend.cpython-38-darwin.so"
egg_name = "cffi-1.14.3-py3.8-macosx-10.15-x86_64.egg" # harded - needs to change
dest_dir = join(self.ctx.dist_dir, "root", "python3", "lib", "python3.8", "site-packages", egg_name)
dest_dir_main = join(self.ctx.dist_dir, "root", "python3", "lib", "python3.8", "site-packages")
src_dir = join(self.ctx.dist_dir, "hostpython3", "lib", "python3.8", "site-packages", egg_name)
2018-06-02 22:17:35 +02:00
sh.cp(join(src_dir, so_file), join(dest_dir, so_file))
2020-09-28 23:29:32 +02:00
sh.cp(join(src_dir, so_file), join(dest_dir_main, so_file))
recipe = CffiRecipe()