使用Android的buildozer编译基于kivy的apk应用程序,要求bcrypt返回错误ModuleNotFoundError:没有名为'setuptools_rust'的模块

问题描述 投票:0回答:1

我是新手所以请原谅我的无知..

我正在尝试按照 kivy 说明和 buildozer 文档中的步骤使用 buildozer 编译基于 kivy 的 apk,我已根据我的要求编辑了 buildozer.spec 文件。

我的 kivy 应用程序在运行 python 3.12.1 的计算机上运行。

我在同一台计算机上使用 Ubuntu wsl 使用 buildozer 编译 apk,其中包含 python 3.10.12 (我想知道这是否是令人困惑的事情)

我的Ubuntu机器使用的是python 3.10.12,pip版本23.3.2,kivy版本2.3.0。

当我运行

buildozer -v android debug
命令时,我不断收到错误:

  RAN: /home/charlie/androidapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v                                                                                                                                                                                     STDOUT:                                                                                                                                                                                                                                               =============================DEBUG ASSISTANCE==========================                                                 If you are seeing an error here please try the following to                                                             successfully install bcrypt:                                                                                                                                                                                                                    Upgrade to the latest pip and try again. This will fix errors for most                                                  users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip                                                     =============================DEBUG ASSISTANCE==========================                                                                                                                                                                 Traceback (most recent call last):                                                                                        File "/home/charlie/androidapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/bcrypt/arm64-v8a__ndk_target_21/bcrypt/setup.py", line 11, in <module>                                                                  from setuptools_rust import RustExtension                                                                           ModuleNotFoundError: No module named 'setuptools_rust'

我的buildozer.spec文件如下:

[app]

# (str) Title of your application
title = Stingray SOS

# (str) Package name
package.name = stingraysos

# (str) Package domain (needed for android/ios packaging)
package.domain = org.stingraysos

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,csv

# (list) List of inclusions using pattern matching
source.include_patterns = assets/*,images/*.png, media/,Plugins/

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = 

# (list) List of directory to exclude (let empty to not exclude anything)
source.exclude_dirs = tests, bin, .venv

# (list) List of exclusions using pattern matching
# Do not prefix with './'
#source.exclude_patterns = license,images/*/*.jpg

# (str) Application versioning (method 1)
#version = 0.1

# (str) Application versioning (method 2)
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python==3.10.12,kivy==2.3.0,bcrypt==4.1.2,mysql-connector-python==8.2.0,requests==2.31.0,setuptools==69.0.3
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/media/watercolor-stingray-sea-animal-png.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/media/watercolor-stingray-sea-animal-png.png

# (list) Supported orientations
# Valid options are: landscape, portrait, portrait-reverse or landscape-reverse
orientation = portrait

# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 3.12.1

# Kivy version to use
osx.kivy_version = 2.3.0

#
# Android specific
#

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0

# (string) Presplash background color (for android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
# red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
# darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
# olive, purple, silver, teal.
#android.presplash_color = #FFFFFF

我已经尝试了错误中建议的内容并升级了pip,我尝试直接使用pip安装setuptools_rust,它说它已经满意了。

我已经通过从我的要求中删除 bcrypt 成功地从 buildozer 中获取了 apk 文件,但该应用程序无法在我的手机上运行。

我也尝试在我的 Ubuntu 机器上使用 python 版本 3.12.1,但 Buildozer 返回 bcrypt 的 distutils 错误...即使 bcrypt 正在使用该版本的我的应用程序中运行。

我尝试将 setuptools_rust 添加到我的 buildozer.spec 文件中的要求中。

我不确定是否正确填写了 buildozer.spec 文件。非常感谢任何帮助。

我觉得我有点在追自己的尾巴,希望有人能给予一些指导。

python android kivy buildozer
1个回答
0
投票

查兹,

在上面提供的代码序列中,“source.dir = .”的目录很重要吗?是红色的?最后一行中的“bin”也是红色的:-

(str) main.py 所在的源代码

源.dir = .

(列表)要包含的源文件(留空以包含所有文件)

source.include_exts = py,png,jpg,kv,atlas,csv

(list) 使用模式匹配的内含物列表

source.include_patterns = 资产/,图片/.png,媒体/,插件/

(列表)要排除的源文件(留空不排除任何内容)

#source.exclude_exts =

(list) 要排除的目录列表(留空不排除任何内容)

source.exclude_dirs = 测试、bin、.venv

© www.soinside.com 2019 - 2024. All rights reserved.