Skip to content

Commit b0f52e7

Browse files
authored
Merge pull request #1209 from mahomahomaho/fix-numpy
fix for #1141 - added ldflags to numpy
2 parents c61c36a + 4ff5833 commit b0f52e7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,36 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
1515
'patches/ar.patch',
1616
'patches/lib.patch']
1717

18+
def get_recipe_env(self, arch):
19+
""" looks like numpy has no proper -L flags. Code copied and adapted from
20+
https://github.com/frmdstryr/p4a-numpy/
21+
"""
22+
23+
env = super(NumpyRecipe, self).get_recipe_env(arch)
24+
#: Hack add path L to crystax as a CFLAG
25+
26+
py_ver = '3.5'
27+
if {'python2crystax', 'python2'} & set(self.ctx.recipe_build_order):
28+
py_ver = '2.7'
29+
30+
py_so = '2.7' if py_ver == '2.7' else '3.5m'
31+
32+
api_ver = self.ctx.android_api
33+
34+
platform = 'arm' if 'arm' in arch.arch else arch.arch
35+
#: Not sure why but we have to inject these into the CC and LD env's for it to
36+
#: use the correct arguments.
37+
flags = " -L{ctx.ndk_dir}/platforms/android-{api_ver}/arch-{platform}/usr/lib/" \
38+
" --sysroot={ctx.ndk_dir}/platforms/android-{api_ver}/arch-{platform}" \
39+
.format(ctx=self.ctx, arch=arch, platform=platform, api_ver=api_ver,
40+
py_so=py_so, py_ver=py_ver)
41+
if flags not in env['CC']:
42+
env['CC'] += flags
43+
if flags not in env['LD']:
44+
env['LD'] += flags + ' -shared'
45+
46+
return env
47+
1848
def prebuild_arch(self, arch):
1949
super(NumpyRecipe, self).prebuild_arch(arch)
2050

0 commit comments

Comments
 (0)