Skip to content

Commit d5120a8

Browse files
committed
Updated numpy recipe to version 1.16.4
Undid unnecessary parts of 1.16.4 recipe change Fully replaced numpy 1.15.1 patches with 1.16.4 patches
1 parent 8ccd0a4 commit d5120a8

File tree

9 files changed

+119
-83
lines changed

9 files changed

+119
-83
lines changed

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55

66
class NumpyRecipe(CompiledComponentsPythonRecipe):
77

8-
version = '1.15.1'
8+
version = '1.16.4'
99
url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip'
1010
site_packages_name = 'numpy'
1111
depends = [('python2', 'python3', 'python3crystax')]
1212

1313
patches = [
14-
join('patches', 'fix-numpy.patch'),
15-
join('patches', 'prevent_libs_check.patch'),
14+
join('patches', 'add_libm_explicitly_to_build.patch'),
15+
join('patches', 'do_not_use_system_libs.patch'),
16+
join('patches', 'remove_unittest_call.patch'),
1617
join('patches', 'ar.patch'),
17-
join('patches', 'lib.patch'),
18-
join('patches', 'python-fixes.patch')
19-
]
18+
join('patches', 'fix_setup_dependencies.patch'),
19+
join('patches', 'fix_environment_detection.patch'),
20+
]
21+
22+
call_hostpython_via_targetpython = False
2023

2124
def build_compiled_components(self, arch):
2225
self.setup_extra_args = ['-j', str(cpu_count())]
@@ -52,6 +55,7 @@ def get_recipe_env(self, arch):
5255
env['CC'] += flags
5356
if flags not in env['LD']:
5457
env['LD'] += flags + ' -shared'
58+
5559
return env
5660

5761

pythonforandroid/recipes/numpy/patches/lib.patch renamed to pythonforandroid/recipes/numpy/patches/add_libm_explicitly_to_build.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/numpy/fft/setup.py b/numpy/fft/setup.py
2-
index cd99a82d7..e614ecd07 100644
2+
index cd99a82..cd7c1ef 100644
33
--- a/numpy/fft/setup.py
44
+++ b/numpy/fft/setup.py
55
@@ -9,7 +9,8 @@ def configuration(parent_package='',top_path=None):
@@ -8,12 +8,12 @@ index cd99a82d7..e614ecd07 100644
88
config.add_extension('fftpack_lite',
99
- sources=['fftpack_litemodule.c', 'fftpack.c']
1010
+ sources=['fftpack_litemodule.c', 'fftpack.c'],
11-
+ libraries=['m']
11+
+ libraries=['m'],
1212
)
1313

1414
return config
1515
diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py
16-
index 66c07c9e1..d34bd930a 100644
16+
index 66c07c9..d34bd93 100644
1717
--- a/numpy/linalg/setup.py
1818
+++ b/numpy/linalg/setup.py
1919
@@ -43,6 +43,7 @@ def configuration(parent_package='', top_path=None):
@@ -34,10 +34,10 @@ index 66c07c9e1..d34bd930a 100644
3434
return config
3535

3636
diff --git a/numpy/random/setup.py b/numpy/random/setup.py
37-
index 3f3b773a4..c1db9f783 100644
37+
index 394a70e..44af180 100644
3838
--- a/numpy/random/setup.py
3939
+++ b/numpy/random/setup.py
40-
@@ -40,7 +40,7 @@ def configuration(parent_package='',top_path=None):
40+
@@ -39,7 +39,7 @@ def configuration(parent_package='',top_path=None):
4141
if needs_mingw_ftime_workaround():
4242
defs.append(("NPY_NEEDS_MINGW_TIME_WORKAROUND", None))
4343

pythonforandroid/recipes/numpy/patches/ar.patch

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
commit 3698b9fad2163728ab3649055b0530bdcaabf8ce
2+
Author: Alexander Taylor <[email protected]>
3+
Date: Mon Jun 24 21:11:47 2019 +0100
4+
5+
ar.patch
6+
17
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
2-
index 632bcb4..c1e0dd5 100644
8+
index 0fac9b0..94be92a 100644
39
--- a/numpy/core/code_generators/generate_umath.py
410
+++ b/numpy/core/code_generators/generate_umath.py
5-
@@ -970,6 +970,7 @@ def make_arrays(funcdict):
11+
@@ -982,6 +982,7 @@ def make_arrays(funcdict):
612
funclist.append('%s_%s' % (tname, name))
713
if t.simd is not None:
814
for vt in t.simd:
@@ -11,30 +17,27 @@ index 632bcb4..c1e0dd5 100644
1117
#ifdef HAVE_ATTRIBUTE_TARGET_{ISA}
1218
if (npy_cpu_supports("{isa}")) {{
1319
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py
14-
index b03fb96..f9e6cd0 100644
20+
index 14451fa..dfd65da 100644
1521
--- a/numpy/distutils/ccompiler.py
1622
+++ b/numpy/distutils/ccompiler.py
17-
@@ -275,6 +275,7 @@ def CCompiler_compile(self, sources, output_dir=None, macros=None,
23+
@@ -295,6 +295,7 @@ def CCompiler_compile(self, sources, output_dir=None, macros=None,
1824
self._setup_compile(output_dir, macros, include_dirs, sources,
1925
depends, extra_postargs)
2026
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
2127
+ cc_args += os.environ['CFLAGS'].split()
2228
display = "compile options: '%s'" % (' '.join(cc_args))
2329
if extra_postargs:
2430
display += "\nextra options: '%s'" % (' '.join(extra_postargs))
31+
@@ -795,4 +796,3 @@ for _cc in ['msvc9', 'msvc', '_msvc', 'bcpp', 'cygwinc', 'emxc', 'unixc']:
32+
_m = sys.modules.get('distutils.' + _cc + 'compiler')
33+
if _m is not None:
34+
setattr(_m, 'gen_lib_options', gen_lib_options)
35+
-
2536
diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py
26-
index 11b2cce..f6dde79 100644
37+
index 11b2cce..c3e9f10 100644
2738
--- a/numpy/distutils/unixccompiler.py
2839
+++ b/numpy/distutils/unixccompiler.py
29-
@@ -54,6 +54,7 @@ def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts
30-
deps = []
31-
32-
try:
33-
+ self.linker_so = [os.environ['LD']+" "+os.environ['LDFLAGS']]
34-
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + deps +
35-
extra_postargs, display = display)
36-
except DistutilsExecError:
37-
@@ -111,6 +112,7 @@ def UnixCCompiler_create_static_lib(self, objects, output_libname,
40+
@@ -111,6 +111,7 @@ def UnixCCompiler_create_static_lib(self, objects, output_libname,
3841
while tmp_objects:
3942
objects = tmp_objects[:50]
4043
tmp_objects = tmp_objects[50:]

pythonforandroid/recipes/numpy/patches/prevent_libs_check.patch renamed to pythonforandroid/recipes/numpy/patches/do_not_use_system_libs.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
2-
index bea120cf9..a448a83fc 100644
2+
index 806f4f7..0d51cfa 100644
33
--- a/numpy/distutils/system_info.py
44
+++ b/numpy/distutils/system_info.py
5-
@@ -719,6 +719,7 @@ class system_info(object):
5+
@@ -734,6 +734,7 @@ class system_info(object):
66
return self.get_paths(self.section, key)
77

88
def get_libs(self, key, default):
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
commit 9a09edac303c534a38c5d829d8537176f8a8dfb9
2+
Author: Alexander Taylor <[email protected]>
3+
Date: Fri Jun 28 22:50:45 2019 +0100
4+
5+
fix_environment_detection.patch
6+
7+
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h
8+
index 64aaaac..e6293f9 100644
9+
--- a/numpy/core/include/numpy/npy_common.h
10+
+++ b/numpy/core/include/numpy/npy_common.h
11+
@@ -164,12 +164,12 @@ extern long long __cdecl _ftelli64(FILE *);
12+
#endif
13+
#else
14+
#ifdef HAVE_FSEEKO
15+
- #define npy_fseek fseeko
16+
+ #define npy_fseek fseek
17+
#else
18+
#define npy_fseek fseek
19+
#endif
20+
#ifdef HAVE_FTELLO
21+
- #define npy_ftell ftello
22+
+ #define npy_ftell ftell
23+
#else
24+
#define npy_ftell ftell
25+
#endif
26+
@@ -321,13 +321,15 @@ typedef unsigned char npy_bool;
27+
#define NPY_TRUE 1
28+
29+
30+
-#if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
31+
- typedef double npy_longdouble;
32+
- #define NPY_LONGDOUBLE_FMT "g"
33+
-#else
34+
- typedef long double npy_longdouble;
35+
- #define NPY_LONGDOUBLE_FMT "Lg"
36+
-#endif
37+
+/* #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE */
38+
+/* typedef double npy_longdouble; */
39+
+/* #define NPY_LONGDOUBLE_FMT "g" */
40+
+/* #else */
41+
+/* typedef long double npy_longdouble; */
42+
+/* #define NPY_LONGDOUBLE_FMT "Lg" */
43+
+/* #endif */
44+
+typedef long double npy_longdouble;
45+
+#define NPY_LONGDOUBLE_FMT "Lg"
46+
47+
#ifndef Py_USING_UNICODE
48+
#error Must use Python with unicode enabled.

pythonforandroid/recipes/numpy/patches/python-fixes.patch renamed to pythonforandroid/recipes/numpy/patches/fix_setup_dependencies.patch

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,11 @@
1-
diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c
2-
index c70f852..695efd5 100644
3-
--- a/numpy/core/src/multiarray/common.c
4-
+++ b/numpy/core/src/multiarray/common.c
5-
@@ -852,3 +852,12 @@ _may_have_objects(PyArray_Descr *dtype)
6-
return (PyDataType_HASFIELDS(base) ||
7-
PyDataType_FLAGCHK(base, NPY_ITEM_HASOBJECT) );
8-
}
9-
+
10-
+/*
11-
+ * Dummy to fix android NDK problem with missing reference.
12-
+ */
13-
+void *
14-
+__emutls_get_address(struct __emutls_object *obj)
15-
+{
16-
+ return NULL;
17-
+}
18-
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py
19-
index 8118e2f..b586442 100644
20-
--- a/numpy/distutils/exec_command.py
21-
+++ b/numpy/distutils/exec_command.py
22-
@@ -260,7 +260,7 @@ def _exec_command(command, use_shell=None, use_tee = None, **env):
23-
return 127, ''
24-
25-
text, err = proc.communicate()
26-
- text = text.decode(locale.getpreferredencoding(False),
27-
+ text = text.decode('UTF-8',
28-
errors='replace')
29-
30-
text = text.replace('\r\n', '\n')
1+
commit 7878dbe20554901aa488553ade19d30e786418e0
2+
Author: Alexander Taylor <[email protected]>
3+
Date: Fri Jun 28 22:49:56 2019 +0100
4+
5+
fix_setup_dependencies.patch
6+
317
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
32-
index f2d677a..758b1ed 100644
8+
index 42374ac..67fcd98 100644
339
--- a/numpy/distutils/misc_util.py
3410
+++ b/numpy/distutils/misc_util.py
3511
@@ -9,7 +9,6 @@ import atexit
@@ -40,23 +16,24 @@ index f2d677a..758b1ed 100644
4016

4117
import distutils
4218
from distutils.errors import DistutilsError
43-
@@ -93,10 +92,7 @@ def get_num_build_jobs():
19+
@@ -94,11 +93,7 @@ def get_num_build_jobs():
4420

4521
"""
4622
from numpy.distutils.core import get_distribution
4723
- try:
4824
- cpu_count = len(os.sched_getaffinity(0))
4925
- except AttributeError:
5026
- cpu_count = multiprocessing.cpu_count()
27+
- cpu_count = min(cpu_count, 8)
5128
+ cpu_count = 1
5229
envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count))
5330
dist = get_distribution()
5431
# may be None during configuration
5532
diff --git a/setup.py b/setup.py
56-
index fed178e..b0266eb 100755
33+
index 8b2ded1..431c1b8 100755
5734
--- a/setup.py
5835
+++ b/setup.py
59-
@@ -377,9 +377,8 @@ def setup_package():
36+
@@ -389,9 +389,8 @@ def setup_package():
6037
# Raise errors for unsupported commands, improve help output, etc.
6138
run_build = parse_setuppy_commands()
6239

Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py
2-
index a7c8593..007ce26 100644
2+
index a8bd4fc..6b01fa6 100644
33
--- a/numpy/testing/__init__.py
44
+++ b/numpy/testing/__init__.py
5-
@@ -1,22 +1,8 @@
6-
-"""Common test support for all numpy test scripts.
7-
+# fake tester, android don't have unittest
8-
+class Tester(object):
9-
+ def test(self, *args, **kwargs):
10-
+ pass
11-
+ def bench(self, *args, **kwargs):
12-
+ pass
13-
+test = Tester().test
5+
@@ -5,18 +5,11 @@ in a single location, so that test scripts can just import it and work right
6+
away.
147

15-
-This single module should provide all the common functionality for numpy tests
16-
-in a single location, so that test scripts can just import it and work right
17-
-away.
18-
-
19-
-"""
8+
"""
209
-from __future__ import division, absolute_import, print_function
21-
-
10+
2211
-from unittest import TestCase
2312
-
2413
-from ._private.utils import *
@@ -29,6 +18,13 @@ index a7c8593..007ce26 100644
2918
-
3019
-__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite']
3120
-
32-
-from ._private.pytesttester import PytestTester
21+
-from numpy._pytesttester import PytestTester
3322
-test = PytestTester(__name__)
3423
-del PytestTester
24+
+# fake tester, android don't have unittest
25+
+class Tester(object):
26+
+ def test(self, *args, **kwargs):
27+
+ pass
28+
+ def bench(self, *args, **kwargs):
29+
+ pass
30+
+test = Tester().test

testapps/setup_testapp_python3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
print('packages are', packages)
2020

2121
setup(
22-
name='testapp_python3_googlendk',
22+
name='python3_googlendk',
2323
version='1.1',
2424
description='p4a setup.py test',
2525
author='Alexander Taylor',

testapps/testapp/main.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
from kivy.utils import platform
2828
print('platform is', platform)
2929

30+
import numpy
31+
print('imported numpy')
32+
from numpy.fft import fft
33+
print('imported fft')
34+
from numpy.random import random
35+
print('imported random')
36+
print(fft(random(10)))
37+
3038

3139
kv = '''
3240
#:import Metrics kivy.metrics.Metrics
@@ -90,7 +98,7 @@
9098
on_touch_down: print('touched at', args[-1].pos)
9199
92100
<ErrorPopup>:
93-
title: 'Error'
101+
title: 'Error'
94102
size_hint: 0.75, 0.75
95103
Label:
96104
text: root.error_text
@@ -128,7 +136,7 @@ def test_pyjnius(self, *args):
128136
except ImportError:
129137
raise_error('Could not import pyjnius')
130138
return
131-
139+
132140
print('Attempting to vibrate with pyjnius')
133141
# PythonActivity = autoclass('org.renpy.android.PythonActivity')
134142
# activity = PythonActivity.mActivity
@@ -142,13 +150,13 @@ def test_pyjnius(self, *args):
142150

143151
def test_ctypes(self, *args):
144152
import ctypes
145-
153+
146154
def test_numpy(self, *args):
147155
import numpy
148156

149157
print(numpy.zeros(5))
150158
print(numpy.arange(5))
151159
print(numpy.random.random((3, 3)))
152-
160+
153161

154162
TestApp().run()

0 commit comments

Comments
 (0)