Skip to content

Commit 4b838f5

Browse files
committed
Made kivy recipe work
1 parent 200fa23 commit 4b838f5

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

recipes/kivy/__init__.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

2-
from toolchain import CythonRecipe, shprint
2+
from toolchain import CythonRecipe, shprint, current_directory, ArchAndroid
3+
from os.path import exists, join
4+
import sh
5+
import glob
36

47

58
class KivyRecipe(CythonRecipe):
@@ -9,5 +12,41 @@ class KivyRecipe(CythonRecipe):
912

1013
depends = ['pygame', 'pyjnius', 'android']
1114

15+
def build_armeabi(self):
16+
env = ArchAndroid(self.ctx).get_env()
17+
18+
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(self.ctx.libs_dir)
19+
env['LDSHARED'] = env['LIBLINK']
20+
21+
# AND: Hack to make pyjnius setup.py detect android build
22+
env['NDKPLATFORM'] = 'NOTNONE'
23+
24+
with current_directory(self.get_actual_build_dir('armeabi')):
25+
if exists('.done'):
26+
print('android module already compiled, exiting')
27+
return
28+
29+
hostpython = sh.Command(self.ctx.hostpython)
30+
31+
print('First build attempt will fail as hostpython doesn\'t have cython available:')
32+
try:
33+
shprint(hostpython, 'setup.py', 'build_ext', _env=env)
34+
except sh.ErrorReturnCode_1:
35+
print('failed (as expected)')
36+
print('Running cython where appropriate')
37+
shprint(sh.find, self.get_actual_build_dir('armeabi'), '-iname', '*.pyx', '-exec',
38+
self.ctx.cython, '{}', ';', _env=env)
39+
print('ran cython')
40+
41+
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env)
42+
43+
build_lib = glob.glob('./build/lib*')
44+
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
45+
env['STRIP'], '{}', ';', _env=env)
46+
47+
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
48+
49+
# AND: Should check in site-packages instead!
50+
sh.touch('.done')
1251

1352
recipe = KivyRecipe()

recipes/pyjnius/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def build_armeabi(self):
2323

2424
# AND: Don't forget to add a check whether pyjnius has already
2525
# been compiled. Currently it redoes it every time.
26+
# AND: This check can be for jnius in site packages
2627

2728
with current_directory(self.get_actual_build_dir('armeabi')):
2829
if exists('.done'):
@@ -44,9 +45,6 @@ def build_armeabi(self):
4445
self.ctx.cython, '{}', ';', _env=env)
4546
print('ran cython')
4647

47-
print('testing')
48-
shprint(sh.echo, 'test', '')
49-
5048
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env)
5149

5250

@@ -58,7 +56,7 @@ def build_armeabi(self):
5856

5957
shprint(sh.cp, '-a', join('jnius', 'src', 'org'), self.ctx.javaclass_dir)
6058

61-
shprint(sh.touch, '.done')
59+
sh.touch('.done')
6260

6361

6462

toolchain.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ def prepare_build_dir(self, ctx):
759759
shprint(sh.rm, '-rf', build_dir)
760760
shprint(sh.mkdir, '-p', build_dir)
761761
shprint(sh.rmdir, build_dir)
762-
shprint(sh.ln, '-s', user_dir, build_dir)
762+
ensure_dir(build_dir)
763+
shprint(sh.ln, '-s', user_dir, join(build_dir, get_directory(self.versioned_url)))
763764
return
764765

765766
ensure_dir(build_dir)
@@ -805,6 +806,7 @@ def prepare_build_dir(self, ctx):
805806
# AND: Should use requests or something for this?
806807
shprint(sh.rm, '-f', marker_filename)
807808
#shprint(sh.wget, filename, url)
809+
print('wgetting') # AND: Use tito's nice function for this
808810
r = requests.get(url)
809811
with open(filename, 'wb') as fileh:
810812
for chunk in r.iter_content():

0 commit comments

Comments
 (0)