Skip to content

Commit 2472b03

Browse files
committed
Fixed numpy compilation and upgraded to 1.9.2
1 parent 33a930f commit 2472b03

File tree

6 files changed

+105
-27
lines changed

6 files changed

+105
-27
lines changed

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
from pythonforandroid.toolchain import CompiledComponentsPythonRecipe, shprint, current_directory
2+
from pythonforandroid.toolchain import CompiledComponentsPythonRecipe, shprint, current_directory, warning
33
from os.path import exists, join
44
import sh
55
import glob
66

77

88
class NumpyRecipe(CompiledComponentsPythonRecipe):
99

10-
version = '1.7.1'
10+
version = '1.9.2'
1111
url = 'http://pypi.python.org/packages/source/n/numpy/numpy-{version}.tar.gz'
1212
site_packages_name= 'numpy'
1313

@@ -21,6 +21,13 @@ def prebuild_arch(self, arch):
2121
return
2222

2323
self.apply_patch('patches/fix-numpy.patch')
24+
self.apply_patch('patches/prevent_libs_check.patch')
25+
self.apply_patch('patches/ar.patch')
26+
self.apply_patch('patches/lib.patch')
27+
28+
# AND: Fix this warning!
29+
warning('Numpy is built assuming the archiver name is '
30+
'arm-linux-androideabi-ar, which may not always be true!')
2431

2532
shprint(sh.touch, join(build_dir, '.patched'))
2633

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/numpy/distutils/unixccompiler.py 2015-02-01 17:38:21.000000000 +0100
2+
+++ b/numpy/distutils/unixccompiler.py 2015-07-08 17:21:05.742468485 +0200
3+
@@ -82,6 +82,8 @@
4+
pass
5+
self.mkpath(os.path.dirname(output_filename))
6+
tmp_objects = objects + self.objects
7+
+ from os import environ
8+
+ self.archiver[0] = 'arm-linux-androideabi-ar'
9+
while tmp_objects:
10+
objects = tmp_objects[:50]
11+
tmp_objects = tmp_objects[50:]

pythonforandroid/recipes/numpy/patches/fix-numpy.patch

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
diff -x build -x '*.pyc' -x '*.swp' -Naur numpy-1.7.1.orig/numpy/core/src/multiarray/numpyos.c numpy-1.7.1/numpy/core/src/multiarray/numpyos.c
2-
--- numpy-1.7.1.orig/numpy/core/src/multiarray/numpyos.c 2013-04-07 07:04:05.000000000 +0200
3-
+++ numpy-1.7.1/numpy/core/src/multiarray/numpyos.c 2013-05-03 10:57:35.812501674 +0200
4-
@@ -170,8 +170,7 @@
1+
diff --git a/numpy/core/src/multiarray/numpyos.c b/numpy/core/src/multiarray/numpyos.c
2+
index 44b32f4..378e199 100644
3+
--- a/numpy/core/src/multiarray/numpyos.c
4+
+++ b/numpy/core/src/multiarray/numpyos.c
5+
@@ -165,8 +165,7 @@ ensure_decimal_point(char* buffer, size_t buf_size)
56
static void
6-
_change_decimal_from_locale_to_dot(char* buffer)
7+
change_decimal_from_locale_to_dot(char* buffer)
78
{
89
- struct lconv *locale_data = localeconv();
910
- const char *decimal_point = locale_data->decimal_point;
1011
+ const char *decimal_point = ".";
1112

1213
if (decimal_point[0] != '.' || decimal_point[1] != 0) {
1314
size_t decimal_point_len = strlen(decimal_point);
14-
@@ -455,8 +454,7 @@
15+
@@ -448,8 +447,7 @@ NumPyOS_ascii_strtod_plain(const char *s, char** endptr)
1516
NPY_NO_EXPORT double
1617
NumPyOS_ascii_strtod(const char *s, char** endptr)
1718
{
@@ -21,40 +22,41 @@ diff -x build -x '*.pyc' -x '*.swp' -Naur numpy-1.7.1.orig/numpy/core/src/multia
2122
size_t decimal_point_len = strlen(decimal_point);
2223

2324
char buffer[FLOAT_FORMATBUFLEN+1];
24-
diff -x build -x '*.pyc' -x '*.swp' -Naur numpy-1.7.1.orig/numpy/core/src/private/npy_config.h numpy-1.7.1/numpy/core/src/private/npy_config.h
25-
--- numpy-1.7.1.orig/numpy/core/src/private/npy_config.h 2013-04-07 07:04:05.000000000 +0200
26-
+++ numpy-1.7.1/numpy/core/src/private/npy_config.h 2013-05-03 10:57:35.812501674 +0200
27-
@@ -41,4 +41,12 @@
28-
#define SIZEOF_PY_INTPTR_T 4
29-
#endif
25+
diff --git a/numpy/core/src/private/npy_config.h b/numpy/core/src/private/npy_config.h
26+
index f768c90..4e5d168 100644
27+
--- a/numpy/core/src/private/npy_config.h
28+
+++ b/numpy/core/src/private/npy_config.h
29+
@@ -41,4 +41,10 @@
30+
#undef HAVE_ATAN2
3031
#endif
31-
+
32-
+/* Android only
33-
+ */
32+
33+
+/* Android only */
3434
+#ifdef ANDROID
3535
+#undef HAVE_LDEXPL
3636
+#undef HAVE_FREXPL
3737
+#endif
3838
+
3939
#endif
40-
diff -x build -x '*.pyc' -x '*.swp' -Naur numpy-1.7.1.orig/numpy/testing/__init__.py numpy-1.7.1/numpy/testing/__init__.py
41-
--- numpy-1.7.1.orig/numpy/testing/__init__.py 2013-04-07 07:04:05.000000000 +0200
42-
+++ numpy-1.7.1/numpy/testing/__init__.py 2013-05-03 11:09:29.316488099 +0200
43-
@@ -1,15 +1,7 @@
40+
diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py
41+
index 258cbe9..ce4e0eb 100644
42+
--- a/numpy/testing/__init__.py
43+
+++ b/numpy/testing/__init__.py
44+
@@ -1,16 +1,7 @@
4445
-"""Common test support for all numpy test scripts.
4546
-
4647
-This single module should provide all the common functionality for numpy tests
4748
-in a single location, so that test scripts can just import it and work right
4849
-away.
50+
-
4951
-"""
52+
-from __future__ import division, absolute_import, print_function
5053
-
5154
-from unittest import TestCase
5255
-
53-
-import decorators as dec
54-
-from utils import *
55-
-from numpytest import *
56-
-from nosetester import NoseTester as Tester
57-
-from nosetester import run_module_suite
56+
-from . import decorators as dec
57+
-from .utils import *
58+
-from .nosetester import NoseTester as Tester
59+
-from .nosetester import run_module_suite
5860
+# fake tester, android don't have unittest
5961
+class Tester(object):
6062
+ def test(self, *args, **kwargs):
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--- a/numpy/linalg/setup.py 2015-07-09 14:15:59.850853336 +0200
2+
+++ b/numpy/linalg/setup.py 2015-07-09 14:21:59.403889000 +0200
3+
@@ -37,7 +37,8 @@
4+
config.add_extension('lapack_lite',
5+
sources = [get_lapack_lite_sources],
6+
depends = ['lapack_litemodule.c'] + lapack_lite_src,
7+
- extra_info = lapack_info
8+
+ extra_info = lapack_info,
9+
+ libraries = ['m'],
10+
)
11+
12+
# umath_linalg module
13+
@@ -46,7 +47,7 @@
14+
sources = [get_lapack_lite_sources],
15+
depends = ['umath_linalg.c.src'] + lapack_lite_src,
16+
extra_info = lapack_info,
17+
- libraries = ['npymath'],
18+
+ libraries = ['npymath','m'],
19+
)
20+
21+
return config
22+
--- a/numpy/fft/setup.py 2015-07-09 14:35:22.299888028 +0200
23+
+++ b/numpy/fft/setup.py 2015-07-09 14:33:54.858392578 +0200
24+
@@ -9,7 +9,8 @@
25+
26+
# Configure fftpack_lite
27+
config.add_extension('fftpack_lite',
28+
- sources=['fftpack_litemodule.c', 'fftpack.c']
29+
+ sources=['fftpack_litemodule.c', 'fftpack.c'],
30+
+ libraries = ['m']
31+
)
32+
33+
34+
--- a/numpy/random/setup.orig.py 2015-07-09 14:44:41.105174826 +0200
35+
+++ b/numpy/random/setup.py 2015-07-09 14:46:08.592679877 +0200
36+
@@ -38,7 +38,7 @@
37+
if needs_mingw_ftime_workaround():
38+
defs.append(("NPY_NEEDS_MINGW_TIME_WORKAROUND", None))
39+
40+
- libs = []
41+
+ libs = ['m']
42+
# Configure mtrand
43+
config.add_extension('mtrand',
44+
sources=[join('mtrand', x) for x in
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
2+
index a050430..471e958 100644
3+
--- a/numpy/distutils/system_info.py
4+
+++ b/numpy/distutils/system_info.py
5+
@@ -610,6 +610,7 @@ class system_info:
6+
return self.get_paths(self.section, key)
7+
8+
def get_libs(self, key, default):
9+
+ return []
10+
try:
11+
libs = self.cp.get(self.section, key)
12+
except NoOptionError:

pythonforandroid/toolchain.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,7 @@ def should_build(self):
14901490
building again.
14911491
14921492
'''
1493+
# AND: This should take arch as an argument!
14931494
return True
14941495

14951496
def build_arch(self, arch):
@@ -1771,7 +1772,8 @@ def build_cython_components(self, arch):
17711772
def get_recipe_env(self, arch):
17721773
env = super(CythonRecipe, self).get_recipe_env(arch)
17731774
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
1774-
self.ctx.get_libs_dir(arch.arch))
1775+
self.ctx.get_libs_dir(arch.arch) +
1776+
'-L{}'.format(self.ctx.libs_dir))
17751777
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')
17761778
env['LIBLINK'] = 'NOTNONE'
17771779
env['NDKPLATFORM'] = self.ctx.ndk_platform

0 commit comments

Comments
 (0)