From 8cd0bcf2b4d3fe5fbff230fe221a789e3574a553 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Wed, 18 Feb 2015 03:01:22 +0100 Subject: [PATCH] pyobjus: new recipe (not tested on arm64) --- recipes/pyobjus/__init__.py | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 recipes/pyobjus/__init__.py diff --git a/recipes/pyobjus/__init__.py b/recipes/pyobjus/__init__.py new file mode 100644 index 0000000..edd8708 --- /dev/null +++ b/recipes/pyobjus/__init__.py @@ -0,0 +1,83 @@ +from toolchain import Recipe, shprint +from os.path import join +import sh +import os +import fnmatch +import shutil + + +class PyobjusRecipe(Recipe): + version = "master" + url = "https://github.com/kivy/pyobjus/archive/{version}.zip" + library = "libpyobjus.a" + depends = ["python"] + + def cythonize(self, filename): + if filename.startswith(self.build_dir): + filename = filename[len(self.build_dir) + 1:] + print("Cythonize {}".format(filename)) + cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) + shprint(cmd, filename) + + def cythonize_build(self): + root_dir = self.build_dir + for root, dirnames, filenames in os.walk(root_dir): + for filename in fnmatch.filter(filenames, "*.pyx"): + self.cythonize(join(root, filename)) + + def get_kivy_env(self, arch): + build_env = arch.get_env() + build_env["KIVYIOSROOT"] = self.ctx.root_dir + build_env["IOSSDKROOT"] = arch.sysroot + build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink") + build_env["CC"] = "{} -I{}".format( + build_env["CC"], + join(self.ctx.dist_dir, "include", arch.arch, "libffi")) + build_env["ARM_LD"] = build_env["LD"] + build_env["ARCH"] = arch.arch + return build_env + + def build_arch(self, arch): + build_env = self.get_kivy_env(arch) + hostpython = sh.Command(self.ctx.hostpython) + try: + shprint(hostpython, "setup.py", "build_ext", "-g", + _env=build_env) + except: + pass + self.cythonize_build() + shprint(sh.sed, + "-i.bak", + "s/ffi\///g", + "pyobjus/pyobjus.c") + shprint(hostpython, "setup.py", "build_ext", "-g", + _env=build_env) + self.biglink() + + def biglink(self): + dirs = [] + for root, dirnames, filenames in os.walk(self.build_dir): + if fnmatch.filter(filenames, "*.so.libs"): + dirs.append(root) + cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink")) + shprint(cmd, join(self.build_dir, "libpyobjus.a"), *dirs) + + def install(self): + arch = list(self.filtered_archs)[0] + build_dir = self.get_build_dir(arch.arch) + os.chdir(build_dir) + hostpython = sh.Command(self.ctx.hostpython) + build_env = self.get_kivy_env(arch) + shprint(hostpython, "setup.py", "install", "-O2", + "--prefix", join(build_dir, "iosbuild"), + _env=build_env) + dest_dir = join(self.ctx.dist_dir, "root", "python", "lib", "python2.7", + "site-packages", "pyobjus") + shutil.copytree( + join(build_dir, "iosbuild", "lib", + "python2.7", "site-packages", "pyobjus"), + dest_dir) + +recipe = PyobjusRecipe() + +