首页 > 解决方案 > 如何为本地目录中的包而不是 zip 文件 url 编写 python-for-android 配方?

问题描述

我有

buildozer.spec
recipes/
  myrecipe/
    __init__.py
mypackage/
  setup.py
  code.py

但是当我尝试用file://谷歌搜索这个问题时看到的 URL 编写一个食谱时,我得到一个错误Exception: Given path is neither a file nor a directory: /home/user/project/.buildozer/android/platform/build-armeabi-v7a/packages/mypackage/mypackage(不是 mypackage 两次)。

我怎样才能做到这一点?

标签: buildozerpython-for-android

解决方案


有一个IncludedFilesBehaviourmixin 就是为了这个,只需给它一个相对路径src_filename

from pythonforandroid.recipe import IncludedFilesBehaviour, CppCompiledComponentsPythonRecipe
import os
import sys

class MyRecipe(IncludedFilesBehaviour, CppCompiledComponentsPythonRecipe):
    version = 'stable'
    src_filename = "../../../phase-engine"
    name = 'phase-engine'

    depends = ['setuptools']

    call_hostpython_via_targetpython = False
    install_in_hostpython = True

    def get_recipe_env(self, arch):
        env = super().get_recipe_env(arch)
        env['LDFLAGS'] += ' -lc++_shared'
        return env

recipe = MyRecipe()

推荐阅读