numpy: new numpy 1.9.1 recipe
This commit is contained in:
parent
7ae3f8efbc
commit
107bc6a49a
2 changed files with 136 additions and 0 deletions
recipes/numpy
80
recipes/numpy/__init__.py
Normal file
80
recipes/numpy/__init__.py
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
from toolchain import Recipe, shprint
|
||||||
|
from os.path import join, exists
|
||||||
|
import sh
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
class NumpyRecipe(Recipe):
|
||||||
|
version = "1.9.1"
|
||||||
|
url = "http://pypi.python.org/packages/source/n/numpy/numpy-{version}.tar.gz"
|
||||||
|
library = "libnumpy.a"
|
||||||
|
libraries = ["libnpymath.a", "libnpysort.a"]
|
||||||
|
depends = ["python"]
|
||||||
|
pbx_frameworks = ["Accelerate"]
|
||||||
|
|
||||||
|
def prebuild_arch(self, arch):
|
||||||
|
if self.has_marker("patched"):
|
||||||
|
return
|
||||||
|
self.apply_patch("numpy-1.9.1.patch")
|
||||||
|
self.set_marker("patched")
|
||||||
|
|
||||||
|
def get_kivy_env(self, arch):
|
||||||
|
build_env = arch.get_env()
|
||||||
|
build_env["KIVYIOSROOT"] = self.ctx.root_dir
|
||||||
|
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
|
||||||
|
build_env["ARM_LD"] = build_env["LD"]
|
||||||
|
# CC must have the CFLAGS with arm arch, because numpy tries first to
|
||||||
|
# compile and execute an empty C to see if the compiler works. This is
|
||||||
|
# obviously not working when crosscompiling
|
||||||
|
build_env["CC"] = "{} {}".format(
|
||||||
|
build_env["CC"],
|
||||||
|
build_env["CFLAGS"])
|
||||||
|
build_env["ARCH"] = arch.arch
|
||||||
|
# Numpy configuration. Don't try to compile anything related to it,
|
||||||
|
# we're going to use the Accelerate framework
|
||||||
|
build_env["NPYCONFIG"] = "env BLAS=None LAPACK=None ATLAS=None"
|
||||||
|
return build_env
|
||||||
|
|
||||||
|
def build_arch(self, arch):
|
||||||
|
build_env = self.get_kivy_env(arch)
|
||||||
|
hostpython = sh.Command(self.ctx.hostpython)
|
||||||
|
shprint(hostpython, "setup.py", "build_ext", "-g", "-v",
|
||||||
|
_env=build_env)
|
||||||
|
sh.cp(sh.glob(join(self.build_dir, "build", "temp.*", "libnpy*.a")),
|
||||||
|
self.build_dir)
|
||||||
|
self.biglink()
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
arch = list(self.filtered_archs)[0]
|
||||||
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
|
os.chdir(build_dir)
|
||||||
|
hostpython = sh.Command(self.ctx.hostpython)
|
||||||
|
build_env = self.get_kivy_env(arch)
|
||||||
|
shprint(hostpython, "setup.py", "install", "-O2",
|
||||||
|
"--prefix", join(build_dir, "iosbuild"),
|
||||||
|
_env=build_env)
|
||||||
|
dest_dir = join(self.ctx.dist_dir, "root", "python", "lib", "python2.7",
|
||||||
|
"site-packages", "numpy")
|
||||||
|
if exists(dest_dir):
|
||||||
|
shutil.rmtree(dest_dir)
|
||||||
|
shutil.copytree(
|
||||||
|
join(build_dir, "iosbuild", "lib",
|
||||||
|
"python2.7", "site-packages", "numpy"),
|
||||||
|
dest_dir)
|
||||||
|
shutil.rmtree(join(dest_dir, "core", "include"))
|
||||||
|
shutil.rmtree(join(dest_dir, "core", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "distutils"))
|
||||||
|
shutil.rmtree(join(dest_dir, "doc"))
|
||||||
|
shutil.rmtree(join(dest_dir, "f2py", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "fft", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "lib", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "ma", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "matrixlib", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "polynomial", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "random", "tests"))
|
||||||
|
shutil.rmtree(join(dest_dir, "tests"))
|
||||||
|
|
||||||
|
recipe = NumpyRecipe()
|
||||||
|
|
||||||
|
|
56
recipes/numpy/numpy-1.9.1.patch
Normal file
56
recipes/numpy/numpy-1.9.1.patch
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
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
|
||||||
|
--- numpy-1.9.1.orig/numpy/core/include/numpy/npy_endian.h 2014-10-26 15:36:14.000000000 +0100
|
||||||
|
+++ numpy-1.9.1.ios/numpy/core/include/numpy/npy_endian.h 2014-11-24 01:59:52.000000000 +0100
|
||||||
|
@@ -6,7 +6,10 @@
|
||||||
|
* endian.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
-#ifdef NPY_HAVE_ENDIAN_H
|
||||||
|
+
|
||||||
|
+//#ifdef NPY_HAVE_ENDIAN_H
|
||||||
|
+//XXX iOS fix, it detects endian.h, but weird detection happen during the compilation
|
||||||
|
+#if 0
|
||||||
|
/* Use endian.h if available */
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
|
diff -Naur numpy-1.9.1.orig/numpy/core/setup.py numpy-1.9.1.ios/numpy/core/setup.py
|
||||||
|
--- numpy-1.9.1.orig/numpy/core/setup.py 2014-10-26 17:22:33.000000000 +0100
|
||||||
|
+++ numpy-1.9.1.ios/numpy/core/setup.py 2014-11-24 01:58:43.000000000 +0100
|
||||||
|
@@ -951,6 +951,9 @@
|
||||||
|
blas_info = get_info('blas_opt', 0)
|
||||||
|
#blas_info = {}
|
||||||
|
def get_dotblas_sources(ext, build_dir):
|
||||||
|
+ # XXX no blas for iOS, maybe it's not needed anymore as our recipe do
|
||||||
|
+ # BLAS=None
|
||||||
|
+ return None
|
||||||
|
if blas_info:
|
||||||
|
if ('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', []):
|
||||||
|
return None # dotblas needs ATLAS, Fortran compiled blas will not be sufficient.
|
||||||
|
diff -Naur numpy-1.9.1.orig/numpy/linalg/setup.py numpy-1.9.1.ios/numpy/linalg/setup.py
|
||||||
|
--- numpy-1.9.1.orig/numpy/linalg/setup.py 2014-10-26 15:36:15.000000000 +0100
|
||||||
|
+++ numpy-1.9.1.ios/numpy/linalg/setup.py 2014-11-24 01:57:48.000000000 +0100
|
||||||
|
@@ -34,8 +34,14 @@
|
||||||
|
return ext.depends[:1]
|
||||||
|
return ext.depends[:2]
|
||||||
|
|
||||||
|
+ def get_lapack_lite_sources_ios(ext, build_dir):
|
||||||
|
+ return ext.depends[:-1]
|
||||||
|
+
|
||||||
|
+ def get_umath_linalg_ios(ext, build_dir):
|
||||||
|
+ return ext.depends[:1]
|
||||||
|
+
|
||||||
|
config.add_extension('lapack_lite',
|
||||||
|
- sources = [get_lapack_lite_sources],
|
||||||
|
+ sources = [get_lapack_lite_sources_ios],
|
||||||
|
depends = ['lapack_litemodule.c'] + lapack_lite_src,
|
||||||
|
extra_info = lapack_info
|
||||||
|
)
|
||||||
|
@@ -43,7 +49,7 @@
|
||||||
|
# umath_linalg module
|
||||||
|
|
||||||
|
config.add_extension('_umath_linalg',
|
||||||
|
- sources = [get_lapack_lite_sources],
|
||||||
|
+ sources = [get_umath_linalg_ios],
|
||||||
|
depends = ['umath_linalg.c.src'] + lapack_lite_src,
|
||||||
|
extra_info = lapack_info,
|
||||||
|
libraries = ['npymath'],
|
Loading…
Add table
Reference in a new issue