11from pythonforandroid .recipe import PythonRecipe , current_directory , \
22 shprint , info_main , warning
33from pythonforandroid .logger import error
4- from os .path import join
4+ from os .path import exists , join
55import sh
66
77
@@ -25,7 +25,8 @@ class TFLiteRuntimeRecipe(PythonRecipe):
2525
2626 version = '2.8.0'
2727 url = 'https://github.com/tensorflow/tensorflow/archive/refs/tags/v{version}.zip'
28- depends = ['pybind11' , 'numpy' ]
28+ depends = ['numpy' ]
29+ hostpython_prerequisites = ['pybind11==2.11.1' ]
2930 patches = ['CMakeLists.patch' , 'build_with_cmake.patch' ]
3031 site_packages_name = 'tflite-runtime'
3132 call_hostpython_via_targetpython = False
@@ -49,6 +50,7 @@ def build_arch(self, arch):
4950 return
5051
5152 env = self .get_recipe_env (arch )
53+ self .install_hostpython_prerequisites ()
5254
5355 # Directories
5456 root_dir = self .get_build_dir (arch .arch )
@@ -58,10 +60,14 @@ def build_arch(self, arch):
5860
5961 # Includes
6062 python_include_dir = self .ctx .python_recipe .include_root (arch .arch )
61- pybind11_recipe = self .get_recipe ('pybind11' , self .ctx )
62- pybind11_include_dir = pybind11_recipe .get_include_dir (arch )
63+ pybind11_include_dir = sh .Command (self .real_hostpython_location )(
64+ '-c' , 'import pybind11; print(pybind11.get_include())'
65+ ).strip ()
6366 numpy_include_dir = join (self .ctx .get_site_packages_dir (arch ),
64- 'numpy' , 'core' , 'include' )
67+ 'numpy' , '_core' , 'include' )
68+ if not exists (numpy_include_dir ):
69+ numpy_include_dir = join (self .ctx .get_site_packages_dir (arch ),
70+ 'numpy' , 'core' , 'include' )
6571 includes = ' -I' + python_include_dir + \
6672 ' -I' + numpy_include_dir + \
6773 ' -I' + pybind11_include_dir
@@ -81,6 +87,7 @@ def build_arch(self, arch):
8187 'ANDROID_ABI' : arch .arch ,
8288 'WRAPPER_INCLUDES' : includes ,
8389 'CMAKE_SHARED_LINKER_FLAGS' : env ['LDFLAGS' ],
90+ 'CMAKE_POLICY_VERSION_MINIMUM' : '3.5' ,
8491 })
8592
8693 try :
0 commit comments