Skip to content

Commit 35126ac

Browse files
committed
Updated NumPy build to v1.14.1.
1 parent 8447e0b commit 35126ac

File tree

3 files changed

+115
-63
lines changed

3 files changed

+115
-63
lines changed

patch/numpy/Makefile.numpy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
# NumPy
33
###########################################################################
44

5-
NUMPY_VERSION=1.9.1
5+
NUMPY_VERSION=1.14.1
66
NUMPY_CONFIG=BLAS=None LAPACK=None ATLAS=None
77

88
# Download original numpy source code archive.
99
downloads/numpy-$(NUMPY_VERSION).tgz:
1010
mkdir -p downloads
11-
# if [ ! -e downloads/numpy-$(NUMPY_VERSION).tgz ]; then curl --fail -L https://github.com/numpy/numpy/releases/download/v$(NUMPY_VERSION)/numpy-$(NUMPY_VERSION).tar.gz -o downloads/numpy-$(NUMPY_VERSION).tgz; fi
12-
if [ ! -e downloads/numpy-$(NUMPY_VERSION).tgz ]; then curl --fail -L https://github.com/numpy/numpy/archive/v$(NUMPY_VERSION).tar.gz -o downloads/numpy-$(NUMPY_VERSION).tgz; fi
11+
if [ ! -e downloads/numpy-$(NUMPY_VERSION).tgz ]; then curl --fail -L https://github.com/numpy/numpy/releases/download/v$(NUMPY_VERSION)/numpy-$(NUMPY_VERSION).tar.gz -o downloads/numpy-$(NUMPY_VERSION).tgz; fi
1312

1413
define build-numpy-target
1514
NUMPY-CFLAGS-$1=$$(CFLAGS-$2)

patch/numpy/README.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ Adding NumPy to your iOS project
4040
" def find_module(self, fullname, mpath=None):\n" \
4141
" if fullname in (" \
4242
" 'numpy.core.multiarray', " \
43-
" 'numpy.core.scalarmath', " \
4443
" 'numpy.core.umath', " \
4544
" 'numpy.fft.fftpack_lite', " \
46-
" 'numpy.lib._compiled_base', " \
4745
" 'numpy.linalg._umath_linalg', " \
4846
" 'numpy.linalg.lapack_lite', " \
4947
" 'numpy.random.mtrand', " \
@@ -66,21 +64,17 @@ Adding NumPy to your iOS project
6664
configures your Python enviroment::
6765

6866
extern PyMODINIT_FUNC PyInit_multiarray(void);
69-
extern PyMODINIT_FUNC PyInit_scalarmath(void);
7067
extern PyMODINIT_FUNC PyInit_umath(void);
7168
extern PyMODINIT_FUNC PyInit_fftpack_lite(void);
72-
extern PyMODINIT_FUNC PyInit__compiled_base(void);
7369
extern PyMODINIT_FUNC PyInit__umath_linalg(void);
7470
extern PyMODINIT_FUNC PyInit_lapack_lite(void);
7571
extern PyMODINIT_FUNC PyInit_mtrand(void);
7672

7773
6. Add the following function calls *before* invoking ``Py_Initialize()``::
7874

7975
PyImport_AppendInittab("__numpy_core_multiarray", &PyInit_multiarray);
80-
PyImport_AppendInittab("__numpy_core_scalarmath", &PyInit_scalarmath);
8176
PyImport_AppendInittab("__numpy_core_umath", &PyInit_umath);
8277
PyImport_AppendInittab("__numpy_fft_fftpack_lite", &PyInit_fftpack_lite);
83-
PyImport_AppendInittab("__numpy_lib__compiled_base", &PyInit__compiled_base);
8478
PyImport_AppendInittab("__numpy_linalg__umath_linalg", &PyInit__umath_linalg);
8579
PyImport_AppendInittab("__numpy_linalg_lapack_lite", &PyInit_lapack_lite);
8680
PyImport_AppendInittab("__numpy_random_mtrand", &PyInit_mtrand);
@@ -114,10 +108,8 @@ folder in the Xcode project) will look something like this::
114108

115109

116110
extern PyMODINIT_FUNC PyInit_multiarray(void);
117-
extern PyMODINIT_FUNC PyInit_scalarmath(void);
118111
extern PyMODINIT_FUNC PyInit_umath(void);
119112
extern PyMODINIT_FUNC PyInit_fftpack_lite(void);
120-
extern PyMODINIT_FUNC PyInit__compiled_base(void);
121113
extern PyMODINIT_FUNC PyInit__umath_linalg(void);
122114
extern PyMODINIT_FUNC PyInit_lapack_lite(void);
123115
extern PyMODINIT_FUNC PyInit_mtrand(void);
@@ -141,10 +133,8 @@ folder in the Xcode project) will look something like this::
141133
putenv((char *)[tmp_path UTF8String]);
142134

143135
PyImport_AppendInittab("__numpy_core_multiarray", &PyInit_multiarray);
144-
PyImport_AppendInittab("__numpy_core_scalarmath", &PyInit_scalarmath);
145136
PyImport_AppendInittab("__numpy_core_umath", &PyInit_umath);
146137
PyImport_AppendInittab("__numpy_fft_fftpack_lite", &PyInit_fftpack_lite);
147-
PyImport_AppendInittab("__numpy_lib__compiled_base", &PyInit__compiled_base);
148138
PyImport_AppendInittab("__numpy_linalg__umath_linalg", &PyInit__umath_linalg);
149139
PyImport_AppendInittab("__numpy_linalg_lapack_lite", &PyInit_lapack_lite);
150140
PyImport_AppendInittab("__numpy_random_mtrand", &PyInit_mtrand);

patch/numpy/numpy.patch

Lines changed: 113 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,119 @@
1-
diff -Naur numpy-1.9.1.orig/numpy/core/include/numpy/npy_endian.h numpy-1.9.1.ios/numpy/core/include/numpy/npy_endian.h
2-
--- numpy-1.9.1.orig/numpy/core/include/numpy/npy_endian.h 2014-10-26 15:36:14.000000000 +0100
3-
+++ numpy-1.9.1.ios/numpy/core/include/numpy/npy_endian.h 2014-11-24 01:59:52.000000000 +0100
4-
@@ -6,7 +6,10 @@
5-
* endian.h
1+
diff -Nru numpy-1.14.1/numpy/_build_utils/apple_accelerate.py numpy/numpy/_build_utils/apple_accelerate.py
2+
--- numpy-1.14.1/numpy/_build_utils/apple_accelerate.py 2018-02-05 09:21:37.000000000 +0800
3+
+++ numpy/numpy/_build_utils/apple_accelerate.py 2018-03-04 13:26:52.000000000 +0800
4+
@@ -8,8 +8,13 @@
5+
6+
def uses_accelerate_framework(info):
7+
""" Returns True if Accelerate framework is used for BLAS/LAPACK """
8+
+ # If we're not building on Darwin (macOS), don't use accelerate
9+
if sys.platform != "darwin":
10+
return False
11+
+ # If we're building on macOS, but targeting a different platform,
12+
+ # don't use accelerate.
13+
+ if os.getenv('_PYTHON_HOST_PLATFORM', None):
14+
+ return False
15+
r_accelerate = re.compile("Accelerate")
16+
extra_link_args = info.get('extra_link_args', '')
17+
for arg in extra_link_args:
18+
diff -Nru numpy-1.14.1/numpy/core/src/multiarray/strfuncs.c numpy/numpy/core/src/multiarray/strfuncs.c
19+
--- numpy-1.14.1/numpy/core/src/multiarray/strfuncs.c 2018-02-20 07:16:17.000000000 +0800
20+
+++ numpy/numpy/core/src/multiarray/strfuncs.c 2018-03-04 13:26:52.000000000 +0800
21+
@@ -41,7 +41,7 @@
22+
* XXX we do this in multiple places; time for a string library?
623
*/
24+
static char *
25+
-extend(char **strp, Py_ssize_t n, Py_ssize_t *maxp)
26+
+extend_str(char **strp, Py_ssize_t n, Py_ssize_t *maxp)
27+
{
28+
char *str = *strp;
29+
Py_ssize_t new_cap;
30+
@@ -71,7 +71,7 @@
31+
npy_intp i, N, ret = 0;
732

8-
-#ifdef NPY_HAVE_ENDIAN_H
33+
#define CHECK_MEMORY do { \
34+
- if (extend(string, *n, max_n) == NULL) { \
35+
+ if (extend_str(string, *n, max_n) == NULL) { \
36+
ret = -1; \
37+
goto end; \
38+
} \
39+
diff -Nru numpy-1.14.1/numpy/distutils/system_info.py numpy/numpy/distutils/system_info.py
40+
--- numpy-1.14.1/numpy/distutils/system_info.py 2018-02-21 01:46:17.000000000 +0800
41+
+++ numpy/numpy/distutils/system_info.py 2018-03-04 13:26:52.000000000 +0800
42+
@@ -219,21 +219,21 @@
43+
_lib_dirs = [
44+
'lib',
45+
]
46+
-
947
+
10-
+//#ifdef NPY_HAVE_ENDIAN_H
11-
+//XXX iOS fix, it detects endian.h, but weird detection happen during the compilation
12-
+#if 0
13-
/* Use endian.h if available */
14-
#include <endian.h>
15-
16-
diff -Naur numpy-1.9.1.orig/numpy/core/setup.py numpy-1.9.1.ios/numpy/core/setup.py
17-
--- numpy-1.9.1.orig/numpy/core/setup.py 2014-10-26 17:22:33.000000000 +0100
18-
+++ numpy-1.9.1.ios/numpy/core/setup.py 2014-11-24 01:58:43.000000000 +0100
19-
@@ -951,6 +951,9 @@
20-
blas_info = get_info('blas_opt', 0)
21-
#blas_info = {}
22-
def get_dotblas_sources(ext, build_dir):
23-
+ # XXX no blas for iOS, maybe it's not needed anymore as our recipe do
24-
+ # BLAS=None
25-
+ return None
26-
if blas_info:
27-
if ('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', []):
28-
return None # dotblas needs ATLAS, Fortran compiled blas will not be sufficient.
29-
diff -Naur numpy-1.9.1.orig/numpy/linalg/setup.py numpy-1.9.1.ios/numpy/linalg/setup.py
30-
--- numpy-1.9.1.orig/numpy/linalg/setup.py 2014-10-26 15:36:15.000000000 +0100
31-
+++ numpy-1.9.1.ios/numpy/linalg/setup.py 2014-11-24 01:57:48.000000000 +0100
32-
@@ -34,8 +34,14 @@
33-
return ext.depends[:1]
34-
return ext.depends[:2]
35-
36-
+ def get_lapack_lite_sources_ios(ext, build_dir):
37-
+ return ext.depends[:-1]
48+
_include_dirs = [d.replace('/', os.sep) for d in _include_dirs]
49+
_lib_dirs = [d.replace('/', os.sep) for d in _lib_dirs]
50+
def add_system_root(library_root):
51+
"""Add a package manager root to the include directories"""
52+
global default_lib_dirs
53+
global default_include_dirs
54+
-
3855
+
39-
+ def get_umath_linalg_ios(ext, build_dir):
40-
+ return ext.depends[:1]
56+
library_root = os.path.normpath(library_root)
57+
-
4158
+
42-
config.add_extension('lapack_lite',
43-
- sources = [get_lapack_lite_sources],
44-
+ sources = [get_lapack_lite_sources_ios],
45-
depends = ['lapack_litemodule.c'] + lapack_lite_src,
46-
extra_info = lapack_info
47-
)
48-
@@ -43,7 +49,7 @@
49-
# umath_linalg module
59+
default_lib_dirs.extend(
60+
os.path.join(library_root, d) for d in _lib_dirs)
61+
default_include_dirs.extend(
62+
os.path.join(library_root, d) for d in _include_dirs)
63+
-
64+
+
65+
if sys.version_info >= (3, 3):
66+
# VCpkg is the de-facto package manager on windows for C/C++
67+
# libraries. If it is on the PATH, then we append its paths here.
68+
@@ -247,7 +247,7 @@
69+
else:
70+
specifier = 'x64'
5071

51-
config.add_extension('_umath_linalg',
52-
- sources = [get_lapack_lite_sources],
53-
+ sources = [get_umath_linalg_ios],
54-
depends = ['umath_linalg.c.src'] + lapack_lite_src,
55-
extra_info = lapack_info,
56-
libraries = ['npymath'],
72+
- vcpkg_installed = os.path.join(vcpkg_dir, 'installed')
73+
+ vcpkg_installed = os.path.join(vcpkg_dir, 'installed')
74+
for vcpkg_root in [
75+
os.path.join(vcpkg_installed, specifier + '-windows'),
76+
os.path.join(vcpkg_installed, specifier + '-windows-static'),
77+
@@ -260,7 +260,7 @@
78+
conda_dir = os.path.dirname(conda)
79+
add_system_root(os.path.join(conda_dir, '..', 'Library'))
80+
add_system_root(os.path.join(conda_dir, 'Library'))
81+
-
82+
+
83+
else:
84+
default_lib_dirs = libpaths(['/usr/local/lib', '/opt/lib', '/usr/lib',
85+
'/opt/local/lib', '/sw/lib'], platform_bits)
86+
@@ -1549,7 +1549,9 @@
87+
if not atlas_info:
88+
atlas_info = get_info('atlas')
89+
90+
- if sys.platform == 'darwin' and not (atlas_info or openblas_info or
91+
+ if sys.platform == 'darwin' \
92+
+ and not os.getenv('_PYTHON_HOST_PLATFORM', None) \
93+
+ and not (atlas_info or openblas_info or
94+
lapack_mkl_info):
95+
# Use the system lapack from Accelerate or vecLib under OSX
96+
args = []
97+
@@ -1655,7 +1657,9 @@
98+
if not atlas_info:
99+
atlas_info = get_info('atlas_blas')
100+
101+
- if sys.platform == 'darwin' and not (atlas_info or openblas_info or
102+
+ if sys.platform == 'darwin' \
103+
+ and not os.getenv('_PYTHON_HOST_PLATFORM', None) \
104+
+ and not (atlas_info or openblas_info or
105+
blas_mkl_info or blis_info):
106+
# Use the system BLAS from Accelerate or vecLib under OSX
107+
args = []
108+
diff -Nru numpy-1.14.1/numpy/linalg/lapack_lite/f2c.h numpy/numpy/linalg/lapack_lite/f2c.h
109+
--- numpy-1.14.1/numpy/linalg/lapack_lite/f2c.h 2018-02-20 07:16:17.000000000 +0800
110+
+++ numpy/numpy/linalg/lapack_lite/f2c.h 2018-03-04 16:12:26.000000000 +0800
111+
@@ -7,6 +7,8 @@
112+
#ifndef F2C_INCLUDE
113+
#define F2C_INCLUDE
114+
115+
+#include <math.h>
116+
+
117+
typedef int integer;
118+
typedef char *address;
119+
typedef short int shortint;

0 commit comments

Comments
 (0)