Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on py2 when import numpy #2003

Merged
merged 1 commit into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pythonforandroid/recipes/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):

call_hostpython_via_targetpython = False

def apply_patches(self, arch, build_dir=None):
if 'python2' in self.ctx.recipe_build_order:
self.patches.append(join('patches', 'fix-py2-numpy-import.patch'))
super().apply_patches(arch, build_dir=build_dir)

def build_compiled_components(self, arch):
self.setup_extra_args = ['-j', str(cpu_count())]
super(NumpyRecipe, self).build_compiled_components(arch)
super().build_compiled_components(arch)
self.setup_extra_args = []

def rebuild_compiled_components(self, arch, env):
self.setup_extra_args = ['-j', str(cpu_count())]
super(NumpyRecipe, self).rebuild_compiled_components(arch, env)
super().rebuild_compiled_components(arch, env)
self.setup_extra_args = []


Expand Down
15 changes: 15 additions & 0 deletions pythonforandroid/recipes/numpy/patches/fix-py2-numpy-import.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
There is an open issue at numpy talking about the import error with numpy:
https://github.com/numpy/numpy/issues/13248
The solution applied here is mentioned there and it seems to only affect our
python2 version.
--- numpy-1.16.4/numpy/core/overrides.py.orig 2019-05-27 12:41:06.000000000 +0200
+++ numpy-1.16.4/numpy/core/overrides.py 2019-10-13 18:51:06.387037239 +0200
@@ -140,6 +140,8 @@ def array_function_dispatch(dispatcher,
-------
Function suitable for decorating the implementation of a NumPy function.
"""
+ if dispatcher.__doc__ is None:
+ dispatcher.__doc__ = ""

if not ENABLE_ARRAY_FUNCTION:
# __array_function__ requires an explicit opt-in for now