Merge pull request #287 from LarsDu/master
Added kivent_core and cymunk recipes
This commit is contained in:
commit
624593b167
2 changed files with 158 additions and 0 deletions
53
recipes/cymunk/__init__.py
Normal file
53
recipes/cymunk/__init__.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
"""
|
||||
Author: Lawrence Du
|
||||
E-mail: larrydu88@gmail.com
|
||||
"""
|
||||
|
||||
from toolchain import CythonRecipe,shprint
|
||||
import os
|
||||
from os.path import join
|
||||
import sh
|
||||
|
||||
class CymunkRecipe(CythonRecipe):
|
||||
version = 'master'
|
||||
url = 'https://github.com/tito/cymunk/archive/{version}.zip'
|
||||
name = 'cymunk'
|
||||
depends = ['hostpython']
|
||||
cythonize = True
|
||||
|
||||
def build_arch(self, arch):
|
||||
"""
|
||||
Override build.arch to avoid calling setup.py here (Call it in
|
||||
install() instead).
|
||||
"""
|
||||
self.cythonize_build()
|
||||
self.biglink()
|
||||
|
||||
|
||||
def install(self):
|
||||
"""
|
||||
Do the equivalent of
|
||||
python setup.py build_ext install
|
||||
while setting the proper environment variables
|
||||
|
||||
"""
|
||||
arch = list(self.filtered_archs)[0]
|
||||
build_env = self.get_recipe_env(arch)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
subdir_path = self.get_build_dir(arch.arch)
|
||||
setup_path = join(subdir_path,"setup.py")
|
||||
dest_dir = join (self.ctx.dist_dir, "root", "python")
|
||||
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
||||
|
||||
#Note: Throws error if PATH is not set. I am not sure if this will cause problems
|
||||
# in other architectures.
|
||||
build_env['PATH']= os.environ.get('PATH')
|
||||
|
||||
shprint(hostpython,
|
||||
setup_path,
|
||||
"build_ext",
|
||||
#"--compiler=mingw32", #note: throws clang error
|
||||
"install",
|
||||
_env=build_env)
|
||||
|
||||
recipe = CymunkRecipe()
|
105
recipes/kivent_core/__init__.py
Normal file
105
recipes/kivent_core/__init__.py
Normal file
|
@ -0,0 +1,105 @@
|
|||
"""
|
||||
Author: Lawrence Du
|
||||
E-mail: larrydu88@gmail.com
|
||||
"""
|
||||
|
||||
from toolchain import CythonRecipe, shprint
|
||||
import sh
|
||||
from os.path import join
|
||||
from os import environ, chdir
|
||||
|
||||
|
||||
|
||||
class KiventCoreRecipe(CythonRecipe):
|
||||
version = 'master'
|
||||
url = 'https://github.com/kivy/kivent/archive/{version}.zip'
|
||||
name = 'kivent_core'
|
||||
depends = ['libffi','kivy'] #note: unsure if libffi is necessary here
|
||||
pre_build_ext=False
|
||||
subbuilddir = False
|
||||
cythonize = True
|
||||
pbx_frameworks = ["OpenGLES"] #note: This line may be unnecessary
|
||||
|
||||
|
||||
def get_recipe_env(self, arch):
|
||||
env = super(KiventCoreRecipe,self).get_recipe_env(arch)
|
||||
env['CYTHONPATH'] = self.get_recipe(
|
||||
'kivy', self.ctx).get_build_dir(arch.arch)
|
||||
return env
|
||||
|
||||
|
||||
def get_build_dir(self,arch, sub=False):
|
||||
"""
|
||||
Call this to get the correct build_dir, where setup.py is located which is
|
||||
actually under modules/core/setup.py
|
||||
"""
|
||||
builddir = super(KiventCoreRecipe, self).get_build_dir(str(arch))
|
||||
if sub or self.subbuilddir:
|
||||
core_build_dir = join (builddir, 'modules', 'core')
|
||||
print "Core build directory is located at {}".format(core_build_dir)
|
||||
return core_build_dir
|
||||
else:
|
||||
print "Building in {}".format(builddir)
|
||||
return builddir
|
||||
|
||||
|
||||
def build_arch(self, arch):
|
||||
"""
|
||||
Override build.arch to avoid calling setup.py here (Call it in
|
||||
install() instead).
|
||||
"""
|
||||
|
||||
self.subbuildir = True
|
||||
self.cythonize_build()
|
||||
self.biglink()
|
||||
self.subbuilddir=False
|
||||
|
||||
|
||||
def install(self):
|
||||
"""
|
||||
This method simply builds the command line call for calling
|
||||
kivent_core/modules/core/setup.py
|
||||
|
||||
This constructs the equivalent of the command
|
||||
"$python2.7 setup.py build_ext install"
|
||||
only with the environment variables altered for each different architecture
|
||||
The appropriate version of kivy also needs to be added to the path, and this
|
||||
differs for each architecture (i386, x86_64, armv7, etc)
|
||||
|
||||
Note: This method is called by build_all() in toolchain.py
|
||||
|
||||
"""
|
||||
arch = list(self.filtered_archs)[0]
|
||||
|
||||
build_dir = self.get_build_dir(arch.arch,sub=True)
|
||||
print "Building kivent_core {} in {}".format(arch.arch,build_dir)
|
||||
chdir(build_dir)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
|
||||
#Get the appropriate environment for this recipe (including CYTHONPATH)
|
||||
#build_env = arch.get_env()
|
||||
build_env = self.get_recipe_env(arch)
|
||||
|
||||
dest_dir = join (self.ctx.dist_dir, "root", "python")
|
||||
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
||||
|
||||
#Add Architecture specific kivy path for 'import kivy' to PYTHONPATH
|
||||
arch_kivy_path = self.get_recipe('kivy', self.ctx).get_build_dir(arch.arch)
|
||||
build_env['PYTHONPATH'] = join( build_env['PYTHONPATH'],':',arch_kivy_path)
|
||||
|
||||
#Make sure you call kivent_core/modules/core/setup.py
|
||||
subdir_path = self.get_build_dir(str(arch),sub=True)
|
||||
setup_path = join(subdir_path,"setup.py")
|
||||
|
||||
|
||||
#Print out directories for sanity check
|
||||
print "ENVS", build_env
|
||||
print "ROOT",self.ctx.root_dir
|
||||
print "BUILD",self.ctx.build_dir
|
||||
print "INCLUDE", self.ctx.include_dir
|
||||
print "DISTDIR", self.ctx.dist_dir
|
||||
print "ARCH KIVY LOC",self.get_recipe('kivy', self.ctx).get_build_dir(arch.arch)
|
||||
|
||||
shprint(hostpython, setup_path, "build_ext", "install", _env=build_env)
|
||||
|
||||
recipe = KiventCoreRecipe()
|
Loading…
Add table
Reference in a new issue