适用于 Android / iOS 和桌面的通用 Python 打包器
项目描述
建造者
Buildozer 是一个用于轻松创建应用程序包的工具。
目标是在您的应用程序目录中有一个“buildozer.spec”文件,描述您的应用程序要求和设置,例如标题、图标、包含的模块等。Buildozer 将使用该规范为 Android、iOS、Windows、OSX 创建一个包和/或 Linux。
Buildozer 目前支持通过python-for-android 项目为 Android 打包,并通过 kivy-ios 项目为 iOS 打包。iOS 和 OSX 仍在工作中。
对于 Android,buildozer 将自动下载并准备构建依赖项。有关详细信息,请参阅 Android-SDK-NDK-Information。请注意,仅支持 Python 3。
请注意,此工具与同名的在线构建服务 buildozer.io 无关。
使用目标 Python 3 安装 Buildozer(默认):
-
安装构建器:
# via pip (latest stable, recommended) # if you use a virtualenv, don't use the `--user` option pip install --user buildozer # latest dev version # if you use a virtualenv, don't use the `--user` option pip install --user https://github.com/kivy/buildozer/archive/master.zip # git clone, for working on buildozer git clone https://github.com/kivy/buildozer cd buildozer python setup.py build pip install -e .
-
检查 buildozer 是否在您的路径中
`which buildozer` # if there is no result, and you installed with --user, add this line at the end of your `~/.bashrc` file. export PATH=~/.local/bin/:$PATH # and then run . ~/.bashrc
-
进入您的应用程序目录并运行:
buildozer init # edit the buildozer.spec, then buildozer android debug deploy run
Buildozer Docker 镜像
Dockerfile 可用于通过 Docker 环境使用 buildozer。
-
构建:
docker build --tag=buildozer .
-
运行:
docker run --volume "$(pwd)":/home/user/hostcwd buildozer --version
Buildozer GitHub 操作
使用ArtemSBulgakov/buildozer-action@v1 根据推送或拉取请求自动构建您的包。请参阅完整的工作流程示例。
Buildozer 命令示例
# buildozer target command
buildozer android clean
buildozer android update
buildozer android deploy
buildozer android debug
buildozer android release
# or all in one (compile in debug, deploy on device)
buildozer android debug deploy
# set the default command if nothing set
buildozer setdefault android debug deploy run
用法
Usage:
buildozer [--profile <name>] [--verbose] [target] <command>...
buildozer --version
Available targets:
android Android target, based on python-for-android project
ios iOS target, based on kivy-ios project
Global commands (without target):
distclean Clean the whole Buildozer environment
help Show the Buildozer help
init Create an initial buildozer.spec in the current directory
serve Serve the bin directory via SimpleHTTPServer
setdefault Set the default command to run when no arguments are given
version Show the Buildozer version
Target commands:
clean Clean the target environment
update Update the target dependencies
debug Build the application in debug mode
release Build the application in release mode
deploy Deploy the application on the device
run Run the application on the device
serve Serve the bin directory via SimpleHTTPServer
Target "ios" commands:
list_identities List the available identities to use for signing.
xcode Open the xcode project.
Target "android" commands:
adb Run adb from the Android SDK. Args must come after --, or
use --alias to make an alias
logcat Show the log from the device
p4a Run p4a commands. Args must come after --, or use --alias
to make an alias
buildozer.spec
有关最新的规范文件,请参阅buildozer/default.spec 。
默认配置
您可以通过设置适当的环境变量来覆盖任何配置令牌的值。 buildozer.spec
这些都是 form $SECTION_TOKEN
,其中 SECTION 是配置文件部分,而 TOKEN 是要覆盖的配置令牌。点被下划线代替。
例如,以下是配置的 [app] 部分中的一些配置标记,以及将覆盖它们的环境变量。
title
->$APP_TITLE
package.name
->$APP_PACKAGE_NAME
p4a.source_dir
->$APP_P4A_SOURCE_DIR
支持
如果您需要帮助,可以通过我们的邮件列表寻求帮助:
不和谐频道:
服务器:https ://chat.kivy.org 频道:#support
对于Android 上的调试,不要犹豫,使用 ADB 来获取应用程序的日志。
贡献
我们喜欢拉请求和讨论新颖的想法。查看我们的 贡献指南并随时改进 buildozer。
以下邮件列表和 IRC 频道专门用于讨论开发 Kivy 框架及其姊妹项目:
我们还有一个 Discord 频道:
- 服务器:https ://chat.kivy.org
- 频道:#支持
执照
Buildozer 是根据 MIT 许可条款发布的。请参阅许可证文件。
支持者
感谢我们所有的支持者!