Skip to content

Commit f8472bd

Browse files
authored
Merge pull request kivy#2003 from opacam/hotfix-py2-import-numpy
Fix error on py2 when `import numpy`
2 parents cb403c9 + 1ad1539 commit f8472bd

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
1818

1919
call_hostpython_via_targetpython = False
2020

21+
def apply_patches(self, arch, build_dir=None):
22+
if 'python2' in self.ctx.recipe_build_order:
23+
self.patches.append(join('patches', 'fix-py2-numpy-import.patch'))
24+
super().apply_patches(arch, build_dir=build_dir)
25+
2126
def build_compiled_components(self, arch):
2227
self.setup_extra_args = ['-j', str(cpu_count())]
23-
super(NumpyRecipe, self).build_compiled_components(arch)
28+
super().build_compiled_components(arch)
2429
self.setup_extra_args = []
2530

2631
def rebuild_compiled_components(self, arch, env):
2732
self.setup_extra_args = ['-j', str(cpu_count())]
28-
super(NumpyRecipe, self).rebuild_compiled_components(arch, env)
33+
super().rebuild_compiled_components(arch, env)
2934
self.setup_extra_args = []
3035

3136

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
There is an open issue at numpy talking about the import error with numpy:
2+
https://github.com/numpy/numpy/issues/13248
3+
The solution applied here is mentioned there and it seems to only affect our
4+
python2 version.
5+
--- numpy-1.16.4/numpy/core/overrides.py.orig 2019-05-27 12:41:06.000000000 +0200
6+
+++ numpy-1.16.4/numpy/core/overrides.py 2019-10-13 18:51:06.387037239 +0200
7+
@@ -140,6 +140,8 @@ def array_function_dispatch(dispatcher,
8+
-------
9+
Function suitable for decorating the implementation of a NumPy function.
10+
"""
11+
+ if dispatcher.__doc__ is None:
12+
+ dispatcher.__doc__ = ""
13+
14+
if not ENABLE_ARRAY_FUNCTION:
15+
# __array_function__ requires an explicit opt-in for now

0 commit comments

Comments
 (0)