Initial commit: EF course autopilot tool
Auto-complete EF English courses with JWT token authentication. Supports multiple task types: multiple-choice, gapfill, matching, flashcards, speaking-practice, text-highlights, sequencing, media-with-time-markers, language-focus. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
打包脚本 — 使用 PyInstaller 将 ef_course_loop.py 打包为单文件可执行程序。
|
||||
|
||||
用法:
|
||||
python3 build.py
|
||||
|
||||
依赖:
|
||||
pip3 install pyinstaller
|
||||
|
||||
注意:需要在目标平台上分别运行打包(PyInstaller 不支持交叉编译)。
|
||||
"""
|
||||
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
system = platform.system()
|
||||
print(f"当前平台: {system}")
|
||||
|
||||
# 检查 PyInstaller
|
||||
if not shutil.which("pyinstaller"):
|
||||
print("❌ 未找到 PyInstaller,请先安装: pip3 install pyinstaller")
|
||||
sys.exit(1)
|
||||
|
||||
# 清理上次打包产物
|
||||
for p in ["build", "dist", "ef_course_autopilot.spec"]:
|
||||
if os.path.exists(p):
|
||||
shutil.rmtree(p) if os.path.isdir(p) else os.remove(p)
|
||||
print(f" 清理: {p}")
|
||||
|
||||
# 根据平台设置输出名称
|
||||
output_name = "ef_course_autopilot.exe" if system == "Windows" else "ef_course_autopilot"
|
||||
|
||||
print("\n开始打包...")
|
||||
cmd = [
|
||||
"pyinstaller",
|
||||
"--onefile",
|
||||
"--name", output_name,
|
||||
"--distpath", "dist",
|
||||
"--workpath", "build",
|
||||
"--specpath", ".",
|
||||
"ef_course_loop.py",
|
||||
]
|
||||
|
||||
result = subprocess.run(cmd)
|
||||
if result.returncode != 0:
|
||||
print(f"\n❌ 打包失败 (exit code: {result.returncode})")
|
||||
sys.exit(1)
|
||||
|
||||
# 打包完成后附带 token.txt.example 到 dist 目录
|
||||
example_src = "token.txt.example"
|
||||
example_dst = os.path.join("dist", example_src)
|
||||
if os.path.exists(example_src):
|
||||
shutil.copy2(example_src, example_dst)
|
||||
|
||||
print(f"\n{'=' * 50}")
|
||||
print(f" ✅ 打包成功!")
|
||||
print(f" 输出: dist/{output_name}")
|
||||
print(f" 提示: 将 token.txt 放在可执行文件同目录下即可运行")
|
||||
print(f"{'=' * 50}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user