Skip to content

Commit 5b3b099

Browse files
committed
Add doc for numpy
1 parent f5e9ee0 commit 5b3b099

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

doc/source/apis.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ https://developer.android.com/reference/android/Manifest.permission
8080
Other common tasks
8181
------------------
8282

83+
Using NumPY
84+
~~~~~~~~~~~
85+
86+
It should work out of the box; just ensure `numpy` is included in your requirements.
87+
If you want better performance, you can also add `libopenblas` to the requirements.
88+
This allows NumPy to use BLAS/LAPACK acceleration, which can significantly improve linear algebra operations.
89+
90+
Keep in mind that `libopenblas` is a fairly large library (~12 MB per architecture),
91+
so it will increase your app size. For example, if you build for 4 architectures,
92+
the APK size may increase by roughly `12 × 4 = 48 MB` (before compression).
93+
8394
Running executables
8495
~~~~~~~~~~~~~~~~~~~
8596

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
class NumpyRecipe(MesonRecipe):
1111
version = "v2.3.0"
1212
url = "git+https://github.com/numpy/numpy"
13-
depends = ["libopenblas"]
14-
extra_build_args = [
15-
"-Csetup-args=-Dblas=auto",
16-
"-Csetup-args=-Dlapack=auto",
17-
"-Csetup-args=-Dallow-noblas=False",
18-
]
13+
opt_depends = ["libopenblas"]
1914
need_stl_shared = True
2015
min_ndk_api_support = 24
2116

@@ -51,6 +46,14 @@ def get_recipe_env(self, arch, **kwargs):
5146
blas_incdir = blas_dir
5247
blas_libdir = join(blas_dir, "lib")
5348
env["CXXFLAGS"] += f" -I{blas_incdir} -L{blas_libdir}"
49+
50+
if 'libopenblas' in self.ctx.recipe_build_order:
51+
self.extra_build_args = [
52+
"-Csetup-args=-Dblas=auto",
53+
"-Csetup-args=-Dlapack=auto",
54+
"-Csetup-args=-Dallow-noblas=False",
55+
]
56+
5457
return env
5558

5659
def get_hostrecipe_env(self, arch=None):

0 commit comments

Comments
 (0)