build: bundle adb platform tools

This commit is contained in:
Your Name committed 2026-06-27 17:59:36 +08:00
1 parent ecbd07cea0
commit f257c4e3fc
11 files changed
+207 -6

No files matched your search

+19 -3
View File
@@ -11,14 +11,30 @@ import shutil
import subprocess
from typing import Optional
from douyin.core import path_config
def _normalize_adb_path(adb: str | None) -> str:
value = str(adb or "").strip()
if value.startswith('"') and value.endswith('"'):
value = value[1:-1]
return value
def find_adb_executable() -> str:
"""返回可用的 adb 可执行文件路径(优先 PATH,其次默认安装目录)。"""
"""返回可用的 adb 可执行文件路径。"""
env_adb = _normalize_adb_path(os.environ.get("ADB_EXECUTABLE"))
if env_adb and os.path.exists(env_adb):
return os.path.abspath(env_adb)
bundled_adb = path_config.find_bundled_adb()
if bundled_adb:
return bundled_adb
adb = shutil.which("adb")
if adb:
return adb
# 默认安装目录(我们之前下载的 platform-tools)
# 默认安装目录(本机开发/打包机常用 platform-tools 位置)
localapp = os.environ.get("LOCALAPPDATA") or ""
candidates = []
if localapp:
@@ -33,7 +49,7 @@ def find_adb_executable() -> str:
for p in candidates:
if os.path.exists(p):
return p
return os.path.abspath(p)
return ""