2019-09-28 18:06:36 +02:00
|
|
|
from toolchain import CythonRecipe, shprint
|
2015-02-25 13:37:52 +01:00
|
|
|
from os.path import join
|
2019-09-28 18:06:36 +02:00
|
|
|
from os import chdir, listdir
|
2015-02-24 12:02:31 +01:00
|
|
|
import sh
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
|
2015-02-25 13:37:52 +01:00
|
|
|
class NumpyRecipe(CythonRecipe):
|
2019-09-28 18:06:36 +02:00
|
|
|
version = "1.16.4"
|
|
|
|
url = "https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip"
|
2015-02-24 12:02:31 +01:00
|
|
|
library = "libnumpy.a"
|
|
|
|
libraries = ["libnpymath.a", "libnpysort.a"]
|
2016-02-14 14:47:35 +01:00
|
|
|
include_dir = "numpy/core/include"
|
2015-02-24 12:02:31 +01:00
|
|
|
depends = ["python"]
|
|
|
|
pbx_frameworks = ["Accelerate"]
|
2015-04-05 10:17:25 +02:00
|
|
|
cythonize = False
|
2015-02-24 12:02:31 +01:00
|
|
|
|
|
|
|
def prebuild_arch(self, arch):
|
|
|
|
if self.has_marker("patched"):
|
|
|
|
return
|
2019-09-28 18:06:36 +02:00
|
|
|
self.apply_patch("numpy-1.16.4.patch")
|
2015-02-24 12:02:31 +01:00
|
|
|
self.set_marker("patched")
|
|
|
|
|
2015-02-25 13:37:52 +01:00
|
|
|
def get_recipe_env(self, arch):
|
|
|
|
env = super(NumpyRecipe, self).get_recipe_env(arch)
|
2015-02-24 12:02:31 +01:00
|
|
|
# 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
|
2015-02-25 13:37:52 +01:00
|
|
|
env["CC"] = "{} {}".format(env["CC"], env["CFLAGS"])
|
2015-02-24 12:02:31 +01:00
|
|
|
# Numpy configuration. Don't try to compile anything related to it,
|
|
|
|
# we're going to use the Accelerate framework
|
2015-02-25 13:37:52 +01:00
|
|
|
env["NPYCONFIG"] = "env BLAS=None LAPACK=None ATLAS=None"
|
|
|
|
return env
|
2015-02-24 12:02:31 +01:00
|
|
|
|
|
|
|
def build_arch(self, arch):
|
2015-02-25 13:37:52 +01:00
|
|
|
super(NumpyRecipe, self).build_arch(arch)
|
2015-02-24 12:02:31 +01:00
|
|
|
sh.cp(sh.glob(join(self.build_dir, "build", "temp.*", "libnpy*.a")),
|
|
|
|
self.build_dir)
|
|
|
|
|
2015-02-25 13:37:52 +01:00
|
|
|
def reduce_python_package(self):
|
|
|
|
dest_dir = join(self.ctx.site_packages_dir, "numpy")
|
2015-02-24 12:02:31 +01:00
|
|
|
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"))
|
|
|
|
|
2019-09-28 18:06:36 +02:00
|
|
|
|
2015-02-24 12:02:31 +01:00
|
|
|
recipe = NumpyRecipe()
|