|
| 1 | +from pythonforandroid.recipe import PyProjectRecipe |
| 2 | +from os.path import join |
| 3 | + |
| 4 | + |
| 5 | +class VideoNativeRecipe(PyProjectRecipe): |
| 6 | + version = "1.0.0" |
| 7 | + url = "https://github.com/Novfensec/VideoNative/archive/{version}.zip" |
| 8 | + name = "videonative" |
| 9 | + site_packages_name = "videonative" |
| 10 | + |
| 11 | + hostpython_prerequisites = ["scikit-build-core", "pybind11", "cmake", "ninja"] |
| 12 | + depends = ["python3", "ffmpeg", "numpy"] |
| 13 | + |
| 14 | + def get_recipe_env(self, arch, **kwargs): |
| 15 | + env = super().get_recipe_env(arch, **kwargs) |
| 16 | + |
| 17 | + ffmpeg_recipe = self.get_recipe("ffmpeg", self.ctx) |
| 18 | + ffmpeg_build_dir = ffmpeg_recipe.get_build_dir(arch.arch) |
| 19 | + |
| 20 | + python_recipe = self.get_recipe("python3", self.ctx) |
| 21 | + py_include_dir = python_recipe.include_root(arch.arch) |
| 22 | + py_lib_file = join( |
| 23 | + python_recipe.get_build_dir(arch.arch), |
| 24 | + "android-build", |
| 25 | + f"libpython{python_recipe.major_minor_version_string}.so", |
| 26 | + ) |
| 27 | + |
| 28 | + toolchain_file = join( |
| 29 | + self.ctx.ndk_dir, "build", "cmake", "android.toolchain.cmake" |
| 30 | + ) |
| 31 | + |
| 32 | + env["SKBUILD_STRICT_CONFIG"] = "false" |
| 33 | + env["SKBUILD_CMAKE_ARGS"] = ( |
| 34 | + f"-DCMAKE_TOOLCHAIN_FILE={toolchain_file};" |
| 35 | + f"-DANDROID_ABI={arch.arch};" |
| 36 | + f"-DANDROID_PLATFORM=android-{self.ctx.ndk_api};" |
| 37 | + f"-DANDROID_FFMPEG_INCLUDE={join(ffmpeg_build_dir, 'include')};" |
| 38 | + f"-DANDROID_FFMPEG_LIB={join(ffmpeg_build_dir, 'lib')};" |
| 39 | + f"-DPython_EXECUTABLE={self.ctx.hostpython};" |
| 40 | + f"-DPython_INCLUDE_DIR={py_include_dir};" |
| 41 | + f"-DPython_LIBRARY={py_lib_file};" |
| 42 | + ) |
| 43 | + |
| 44 | + return env |
| 45 | + |
| 46 | + |
| 47 | +recipe = VideoNativeRecipe() |
0 commit comments