-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_colab.py
More file actions
42 lines (35 loc) · 1.24 KB
/
build_colab.py
File metadata and controls
42 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Google Colab 构建脚本
直接在 Colab 中运行此文件
"""
# 安装依赖
print("📦 安装 Python 依赖...")
import subprocess
subprocess.run(["pip", "install", "buildozer", "cython"], check=True)
# 克隆项目
print("📥 克隆项目...")
subprocess.run(["git", "clone", "https://github.com/Michael-YuQ/python-calculator-android.git"], check=True)
import os
os.chdir("python-calculator-android")
# 安装系统依赖
print("🔧 安装系统依赖...")
apt_packages = [
"git", "zip", "unzip", "openjdk-17-jdk", "wget",
"autoconf", "libtool", "pkg-config", "zlib1g-dev",
"libncurses5-dev", "libncursesw5-dev", "libtinfo5",
"cmake", "libffi-dev", "libssl-dev"
]
subprocess.run(["apt-get", "update"], check=True)
subprocess.run(["apt-get", "install", "-y"] + apt_packages, check=True)
# 构建 APK
print("🏗️ 开始构建 APK(这需要 15-20 分钟)...")
subprocess.run(["buildozer", "android", "debug"], check=True)
# 下载 APK
print("⬇️ 准备下载 APK...")
from google.colab import files
apk_files = [f for f in os.listdir('bin') if f.endswith('.apk')]
if apk_files:
files.download(f'bin/{apk_files[0]}')
print(f"✅ 成功!APK 已下载: {apk_files[0]}")
else:
print("❌ 错误:未找到 APK 文件")