recipes: update all Cython/Python recipe to use new classes

This commit is contained in:
Mathieu Virbel 2015-02-25 13:37:52 +01:00
parent c0f5cae59a
commit f23f86dfef
6 changed files with 47 additions and 252 deletions

View file

@ -1,56 +1,13 @@
from toolchain import Recipe, shprint from toolchain import CythonRecipe
from os.path import join
import sh
import os
import shutil
class AudiostreamRecipe(Recipe): class AudiostreamRecipe(CythonRecipe):
version = "master" version = "master"
url = "https://github.com/kivy/audiostream/archive/{version}.zip" url = "https://github.com/kivy/audiostream/archive/{version}.zip"
library = "libaudiostream.a" library = "libaudiostream.a"
depends = ["python", "sdl2"] depends = ["python", "sdl2"]
pre_build_ext = True
def get_kivy_env(self, arch):
build_env = arch.get_env()
build_env["KIVYIOSROOT"] = self.ctx.root_dir
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
build_env["ARM_LD"] = build_env["LD"]
build_env["CC"] = "{} -I{}".format(
build_env["CC"],
join(self.ctx.dist_dir, "include", "common", "sdl2"))
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(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
self.biglink()
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", "audiostream")
shutil.copytree(
join(build_dir, "iosbuild", "lib",
"python2.7", "site-packages", "audiostream"),
dest_dir)
recipe = AudiostreamRecipe() recipe = AudiostreamRecipe()

View file

@ -1,66 +1,30 @@
from toolchain import Recipe, shprint from toolchain import CythonRecipe, shprint
from os.path import join from os.path import join
import sh import sh
import os
import fnmatch
import shutil
class FFPyplayerRecipe(Recipe): class FFPyplayerRecipe(CythonRecipe):
version = "master" version = "master"
url = "https://github.com/tito/ffpyplayer/archive/{version}.zip" url = "https://github.com/matham/ffpyplayer/archive/{version}.zip"
library = "libffpyplayer.a" library = "libffpyplayer.a"
depends = ["python", "ffmpeg"] depends = ["python", "ffmpeg"]
pbx_frameworks = [ pbx_frameworks = [
"CoreVideo", "CoreMedia", "CoreImage", "AVFoundation", "UIKit", "CoreVideo", "CoreMedia", "CoreImage", "AVFoundation", "UIKit",
"CoreMotion"] "CoreMotion"]
pbx_libraries = ["libiconv"] pbx_libraries = ["libiconv"]
pre_build_ext = True
def get_kivy_env(self, arch): def get_recipe_env(self, arch):
build_env = arch.get_env() env = super(FFPyplayerRecipe, self).get_recipe_env(arch)
build_env["KIVYIOSROOT"] = self.ctx.root_dir env["CC"] += " -I{}".format(
build_env["IOSSDKROOT"] = arch.sysroot join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink") env["SDL_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include",
build_env["CC"] = "{} -I{}".format( "common", "sdl2")
build_env["CC"], env["FFMPEG_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include",
join(self.ctx.dist_dir, "include", arch.arch, "libffi")) arch.arch, "ffmpeg")
build_env["ARM_LD"] = build_env["LD"] env["CONFIG_POSTPROC"] = "0"
build_env["ARCH"] = arch.arch return env
build_env["SDL_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include",
"common", "sdl2")
build_env["FFMPEG_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include",
arch.arch, "ffmpeg")
build_env["CONFIG_POSTPROC"] = "0"
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(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
self.biglink()
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", "ffpyplayer")
shutil.copytree(
join(build_dir, "iosbuild", "lib",
"python2.7", "site-packages", "ffpyplayer"),
dest_dir)
recipe = FFPyplayerRecipe() recipe = FFPyplayerRecipe()

View file

@ -1,50 +1,16 @@
from toolchain import Recipe, shprint from toolchain import CythonRecipe
from os.path import join, exists
import sh
import os
import fnmatch
import shutil
class IosRecipe(Recipe): class IosRecipe(CythonRecipe):
version = "master" version = "master"
url = "src" url = "src"
library = "libios.a" library = "libios.a"
depends = ["python"] depends = ["python"]
pbx_frameworks = ["MessageUI", "CoreMotion", "UIKit"] pbx_frameworks = ["MessageUI", "CoreMotion", "UIKit"]
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["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)
self.cythonize_build()
shprint(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
self.biglink()
def install(self): def install(self):
arch = list(self.filtered_archs)[0] self.install_python_package(name="ios.so", is_dir=False)
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", "ios.so")
shutil.copy(
join(build_dir, "iosbuild", "lib",
"python2.7", "site-packages", "ios.so"),
dest_dir)
recipe = IosRecipe() recipe = IosRecipe()

View file

@ -12,35 +12,20 @@ class KivyRecipe(Recipe):
library = "libkivy.a" library = "libkivy.a"
depends = ["python", "sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios"] depends = ["python", "sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios"]
pbx_frameworks = ["OpenGLES", "Accelerate"] pbx_frameworks = ["OpenGLES", "Accelerate"]
pre_build_ext = True
def get_kivy_env(self, arch): def get_recipe_env(self, arch):
build_env = arch.get_env() env = super(KivyRecipe, self).get_recipe_env(arch)
build_env["KIVYIOSROOT"] = self.ctx.root_dir env["KIVY_SDL2_PATH"] = ":".join([
build_env["IOSSDKROOT"] = arch.sysroot
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
build_env["ARM_LD"] = build_env["LD"]
build_env["ARCH"] = arch.arch
build_env["KIVY_SDL2_PATH"] = ":".join([
join(self.ctx.dist_dir, "include", "common", "sdl2"), 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_image"),
join(self.ctx.dist_dir, "include", "common", "sdl2_ttf"), join(self.ctx.dist_dir, "include", "common", "sdl2_ttf"),
join(self.ctx.dist_dir, "include", "common", "sdl2_mixer")]) join(self.ctx.dist_dir, "include", "common", "sdl2_mixer")])
return build_env return env
def build_arch(self, arch): def build_arch(self, arch):
self._patch_setup() self._patch_setup()
build_env = self.get_kivy_env(arch) super(KivyRecipe, self).build_arch(arch)
hostpython = sh.Command(self.ctx.hostpython)
# first try to generate .h
try:
shprint(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
except:
pass
self.cythonize_build()
shprint(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
self.biglink()
def _patch_setup(self): def _patch_setup(self):
# patch setup to remove some functionnalities # patch setup to remove some functionnalities
@ -56,24 +41,6 @@ class KivyRecipe(Recipe):
with open(pyconfig, "wb") as fd: with open(pyconfig, "wb") as fd:
fd.writelines(lines) fd.writelines(lines)
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", "kivy")
if exists(dest_dir):
shutil.rmtree(dest_dir)
shutil.copytree(
join(build_dir, "iosbuild", "lib",
"python2.7", "site-packages", "kivy"),
dest_dir)
recipe = KivyRecipe() recipe = KivyRecipe()

View file

@ -1,11 +1,10 @@
from toolchain import Recipe, shprint from toolchain import CythonRecipe
from os.path import join, exists from os.path import join
import sh import sh
import os
import shutil import shutil
class NumpyRecipe(Recipe): class NumpyRecipe(CythonRecipe):
version = "1.9.1" version = "1.9.1"
url = "http://pypi.python.org/packages/source/n/numpy/numpy-{version}.tar.gz" url = "http://pypi.python.org/packages/source/n/numpy/numpy-{version}.tar.gz"
library = "libnumpy.a" library = "libnumpy.a"
@ -19,49 +18,24 @@ class NumpyRecipe(Recipe):
self.apply_patch("numpy-1.9.1.patch") self.apply_patch("numpy-1.9.1.patch")
self.set_marker("patched") self.set_marker("patched")
def get_kivy_env(self, arch): def get_recipe_env(self, arch):
build_env = arch.get_env() env = super(NumpyRecipe, self).get_recipe_env(arch)
build_env["KIVYIOSROOT"] = self.ctx.root_dir
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
build_env["ARM_LD"] = build_env["LD"]
# CC must have the CFLAGS with arm arch, because numpy tries first to # CC must have the CFLAGS with arm arch, because numpy tries first to
# compile and execute an empty C to see if the compiler works. This is # compile and execute an empty C to see if the compiler works. This is
# obviously not working when crosscompiling # obviously not working when crosscompiling
build_env["CC"] = "{} {}".format( env["CC"] = "{} {}".format(env["CC"], env["CFLAGS"])
build_env["CC"],
build_env["CFLAGS"])
build_env["ARCH"] = arch.arch
# Numpy configuration. Don't try to compile anything related to it, # Numpy configuration. Don't try to compile anything related to it,
# we're going to use the Accelerate framework # we're going to use the Accelerate framework
build_env["NPYCONFIG"] = "env BLAS=None LAPACK=None ATLAS=None" env["NPYCONFIG"] = "env BLAS=None LAPACK=None ATLAS=None"
return build_env return env
def build_arch(self, arch): def build_arch(self, arch):
build_env = self.get_kivy_env(arch) super(NumpyRecipe, self).build_arch(arch)
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, "setup.py", "build_ext", "-g", "-v",
_env=build_env)
sh.cp(sh.glob(join(self.build_dir, "build", "temp.*", "libnpy*.a")), sh.cp(sh.glob(join(self.build_dir, "build", "temp.*", "libnpy*.a")),
self.build_dir) self.build_dir)
self.biglink()
def install(self): def reduce_python_package(self):
arch = list(self.filtered_archs)[0] dest_dir = join(self.ctx.site_packages_dir, "numpy")
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", "numpy")
if exists(dest_dir):
shutil.rmtree(dest_dir)
shutil.copytree(
join(build_dir, "iosbuild", "lib",
"python2.7", "site-packages", "numpy"),
dest_dir)
shutil.rmtree(join(dest_dir, "core", "include")) shutil.rmtree(join(dest_dir, "core", "include"))
shutil.rmtree(join(dest_dir, "core", "tests")) shutil.rmtree(join(dest_dir, "core", "tests"))
shutil.rmtree(join(dest_dir, "distutils")) shutil.rmtree(join(dest_dir, "distutils"))

View file

@ -1,60 +1,27 @@
from toolchain import Recipe, shprint from toolchain import CythonRecipe, shprint
from os.path import join from os.path import join
import sh import sh
import os
import shutil
class PyobjusRecipe(Recipe): class PyobjusRecipe(CythonRecipe):
version = "master" version = "master"
url = "https://github.com/kivy/pyobjus/archive/{version}.zip" url = "https://github.com/kivy/pyobjus/archive/{version}.zip"
library = "libpyobjus.a" library = "libpyobjus.a"
depends = ["python"] depends = ["python"]
pre_build_ext = True
def get_kivy_env(self, arch): def get_recipe_env(self, arch):
build_env = arch.get_env() env = super(PyobjusRecipe, self).get_recipe_env(arch)
build_env["KIVYIOSROOT"] = self.ctx.root_dir env["CC"] += " -I{}".format(
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")) join(self.ctx.dist_dir, "include", arch.arch, "libffi"))
build_env["ARM_LD"] = build_env["LD"] return env
build_env["ARCH"] = arch.arch
return build_env
def build_arch(self, arch): def cythonize_build(self):
build_env = self.get_kivy_env(arch) super(PyobjusRecipe, self).cythonize_build()
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, shprint(sh.sed,
"-i.bak", "-i.bak",
"s/ffi\///g", "s/ffi\///g",
"pyobjus/pyobjus.c") "pyobjus/pyobjus.c")
shprint(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
self.biglink()
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() recipe = PyobjusRecipe()