1
1
from pythonforandroid .recipe import CompiledComponentsPythonRecipe , Recipe
2
2
from multiprocessing import cpu_count
3
3
from os .path import join
4
+ from os import environ
5
+ from pythonforandroid .util import build_platform
6
+
7
+ arch_to_sysroot = {'armeabi' : 'arm' , 'armeabi-v7a' : 'arm' , 'arm64-v8a' : 'arm64' }
4
8
5
9
6
10
class ScipyRecipe (CompiledComponentsPythonRecipe ):
7
11
8
- version = '1.5.4 '
12
+ version = '1.8.1 '
9
13
url = f'https://github.com/scipy/scipy/releases/download/v{ version } /scipy-{ version } .zip'
10
14
site_packages_name = 'scipy'
11
- depends = ['setuptools' , 'cython' , 'numpy' , 'lapack' ]
15
+ depends = ['setuptools' , 'cython' , 'numpy' , 'lapack' , 'pybind11' ]
12
16
call_hostpython_via_targetpython = False
17
+ need_stl_shared = True
13
18
14
19
def build_compiled_components (self , arch ):
15
20
self .setup_extra_args = ['-j' , str (cpu_count ())]
@@ -24,27 +29,42 @@ def rebuild_compiled_components(self, arch, env):
24
29
def get_recipe_env (self , arch ):
25
30
env = super ().get_recipe_env (arch )
26
31
32
+ ndk_dir = environ ["LEGACY_NDK" ]
27
33
GCC_VER = '4.9'
28
- HOST = 'linux-x86_64'
29
- LIB = 'lib64 ' if '64' in arch .arch else 'lib '
34
+ HOST = build_platform
35
+ suffix = '64 ' if '64' in arch .arch else ''
30
36
31
- lapack_dir = join (Recipe .get_recipe ('lapack' , self .ctx ).get_build_dir (arch .arch ), 'build' , 'install' )
32
- sysroot = f"{ self .ctx .ndk_dir } /platforms/{ env ['NDK_API' ]} /{ arch .platform_dir } "
33
- sysroot_include = f'{ self .ctx .ndk_dir } /toolchains/llvm/prebuilt/{ HOST } /sysroot/usr/include'
34
- prefix = "" # FIXME
35
- libgfortran = f'{ self .ctx .ndk_dir } /toolchains/{ prefix } -{ GCC_VER } /prebuilt/{ HOST } /{ prefix } /{ LIB } '
36
- numpylib = self .ctx .get_python_install_dir (arch .arch ) + '/numpy/core/lib'
37
+ prefix = arch .command_prefix
38
+ sysroot_suffix = arch_to_sysroot .get (arch .arch , arch .arch )
39
+ sysroot = f"{ ndk_dir } /platforms/{ env ['NDK_API' ]} /arch-{ sysroot_suffix } "
40
+ sysroot_include = f'{ ndk_dir } /toolchains/llvm/prebuilt/{ HOST } /sysroot/usr/include'
41
+ CLANG_BIN = f'{ ndk_dir } /toolchains/llvm/prebuilt/{ HOST } /bin/'
42
+ GCC = f'{ ndk_dir } /toolchains/{ prefix } -{ GCC_VER } /prebuilt/{ HOST } '
43
+ libgfortran = f'{ GCC } /{ prefix } /lib{ suffix } '
44
+
45
+ numpylib = self .ctx .get_python_install_dir (arch .arch ) + '/numpy'
37
46
LDSHARED_opts = env ['LDSHARED' ].split ('clang' )[1 ]
47
+ arch_cflags = ' ' .join (arch .arch_cflags )
38
48
49
+ # TODO: add pythran support
50
+ env ['SCIPY_USE_PYTHRAN' ] = '0'
51
+
52
+ lapack_dir = join (Recipe .get_recipe ('lapack' , self .ctx ).get_build_dir (arch .arch ), 'build' , 'install' )
39
53
env ['LAPACK' ] = f'{ lapack_dir } /lib'
40
54
env ['BLAS' ] = env ['LAPACK' ]
41
- env ['F90' ] = f'{ prefix } -gfortran'
42
- env ['CXX' ] += f' -Wl,-l{ self .stl_lib_name } -Wl,-L{ self .get_stl_lib_dir (arch )} '
43
- env ['CPPFLAGS' ] += f' --sysroot={ sysroot } -I{ sysroot_include } /c++/v1 -I{ sysroot_include } '
44
- env ['LDSHARED' ] = 'clang'
45
- env ['LDFLAGS' ] += f' { LDSHARED_opts } --sysroot={ sysroot } -L{ libgfortran } -L{ numpylib } '
46
- env ['LDFLAGS' ] += f' -L{ self .ctx .ndk_dir } /sources/cxx-stl/llvm-libc++/libs/{ arch .arch } /'
47
55
56
+ # compilers
57
+ env ['F77' ] = f'{ GCC } /bin/{ prefix } -gfortran'
58
+ env ['F90' ] = f'{ GCC } /bin/{ prefix } -gfortran'
59
+ env ['CC' ] = f'{ CLANG_BIN } /clang -target { arch .target } { arch_cflags } '
60
+ env ['CXX' ] = f'{ CLANG_BIN } /clang++ -target { arch .target } { arch_cflags } '
61
+ env ['LDSHARED' ] = f'{ CLANG_BIN } /clang'
62
+
63
+ # flags
64
+ env ['CPPFLAGS' ] = f'-DANDROID -I{ sysroot_include } /{ prefix } --sysroot={ sysroot } -I{ sysroot_include } /c++/v1 -I{ sysroot_include } '
65
+ env ['LDFLAGS' ] += f' { LDSHARED_opts } --sysroot={ sysroot } -L{ libgfortran } -L{ numpylib } /core/lib -L{ numpylib } /random/lib'
66
+ env ['LDFLAGS' ] += f' -l{ self .stl_lib_name } '
67
+ env ['LDFLAGS' ] += f' -L{ ndk_dir } /sources/cxx-stl/llvm-libc++/libs/{ arch .arch } /' # for arm32 - unwind
48
68
return env
49
69
50
70
0 commit comments