-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy path__init__.py
More file actions
66 lines (53 loc) · 2.21 KB
/
Copy path__init__.py
File metadata and controls
66 lines (53 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pythonforandroid.recipe import Recipe, MesonRecipe
from os.path import join
import shutil
NUMPY_NDK_MESSAGE = (
"In order to build numpy, you must set minimum ndk api (minapi) to `24`.\n"
)
class NumpyRecipe(MesonRecipe):
version = "v2.3.0"
url = "git+https://github.com/numpy/numpy"
extra_build_args = ["-Csetup-args=-Dblas=none", "-Csetup-args=-Dlapack=none"]
opt_depends = ["libopenblas"]
need_stl_shared = True
min_ndk_api_support = 24
def get_include(self, arch):
return join(
self.ctx.get_python_install_dir(arch.arch), "numpy/_core/include",
)
def get_recipe_meson_options(self, arch):
options = super().get_recipe_meson_options(arch)
options["properties"]["longdouble_format"] = (
"IEEE_DOUBLE_LE" if arch.arch in ["armeabi-v7a", "x86"] else "IEEE_QUAD_LE"
)
return options
def get_recipe_env(self, arch, **kwargs):
env = super().get_recipe_env(arch, **kwargs)
# _PYTHON_HOST_PLATFORM declares that we're cross-compiling
# and avoids issues when building on macOS for Android targets.
env["_PYTHON_HOST_PLATFORM"] = arch.command_prefix
# NPY_DISABLE_SVML=1 allows numpy to build for non-AVX512 CPUs
# See: https://github.com/numpy/numpy/issues/21196
env["NPY_DISABLE_SVML"] = "1"
env["TARGET_PYTHON_EXE"] = join(
Recipe.get_recipe("python3", self.ctx).get_build_dir(arch.arch),
"android-build",
"python",
)
blas_dir = join(Recipe.get_recipe("libopenblas", self.ctx
).get_build_dir(arch.arch), "build")
blas_incdir = blas_dir
blas_libdir = join(blas_dir, "lib")
env["CXXFLAGS"] += f" -I{blas_incdir} -L{blas_libdir}"
if 'libopenblas' in self.ctx.recipe_build_order:
self.extra_build_args = [
"-Csetup-args=-Dblas=auto",
"-Csetup-args=-Dlapack=auto",
"-Csetup-args=-Dallow-noblas=False",
]
return env
def get_hostrecipe_env(self, arch=None):
env = super().get_hostrecipe_env(arch=arch)
env["RANLIB"] = shutil.which("ranlib")
return env
recipe = NumpyRecipe()