- diagnostics/ 11 个:环境/配置/依赖诊断 - logs/ 7 个:日志分析与查看 - coords/ 6 个:坐标拾取与区域选择 - cleanup/ 3 个:代码清理工具 - adb/ 2 个:ADB / 输入法相关 - windows/ 4 个:Windows 系统修复(备份) - dev/ 9 个:开发辅助 / 运行时探测 并更新 tools/README.md 描述新结构。 删除 3 个明显的临时调试脚本 (_dump_lines.py / tmp_*.py)。 tools/ 不被业务代码 import,分组仅为人工浏览方便。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""自动安装缺失的依赖"""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
def install_package(package):
|
|
"""安装指定的包"""
|
|
try:
|
|
print(f"Installing {package}...")
|
|
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
|
print(f"[SUCCESS] {package} installed successfully")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"[ERROR] Failed to install {package}: {e}")
|
|
return False
|
|
|
|
def main():
|
|
# 检查缺失的依赖
|
|
missing = []
|
|
|
|
try:
|
|
import paddle # type: ignore[import-untyped]
|
|
except ImportError:
|
|
missing.append("paddlepaddle>=3.0.0")
|
|
|
|
try:
|
|
import ttkbootstrap
|
|
except ImportError:
|
|
missing.append("ttkbootstrap>=1.10.0")
|
|
|
|
if not missing:
|
|
print("[SUCCESS] All dependencies are installed!")
|
|
return 0
|
|
|
|
print(f"Missing dependencies: {', '.join(missing)}")
|
|
print("\nDo you want to install them? (y/n): ", end='')
|
|
|
|
# 在非交互环境中自动安装
|
|
response = 'y'
|
|
try:
|
|
response = input().strip().lower()
|
|
except (EOFError, KeyboardInterrupt):
|
|
response = 'y' # 默认安装
|
|
|
|
if response in ('y', 'yes', ''):
|
|
success_count = 0
|
|
for pkg in missing:
|
|
if install_package(pkg):
|
|
success_count += 1
|
|
|
|
if success_count == len(missing):
|
|
print("\n[SUCCESS] All dependencies installed successfully!")
|
|
return 0
|
|
else:
|
|
print(f"\n[WARNING] {len(missing) - success_count} package(s) failed to install")
|
|
print("You may need to install them manually:")
|
|
print(f"pip install {' '.join(missing)}")
|
|
return 1
|
|
else:
|
|
print("Installation cancelled.")
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|