chore: 分发包改用 WebView2 在线安装器

This commit is contained in:
Nixevol
2026-10-25 05:49:44 +08:00
parent f53498f6e6
commit 2286bc597d
3 changed files with 16 additions and 11 deletions
+8 -3
View File
@@ -4,7 +4,7 @@
python scripts/package.py
Windows 会编译界面和桌面程序,并拷贝本地已有的 Python 缓存、adb、ffmpeg 和 WebView2 离线安装包。
Windows 会编译界面和桌面程序,并拷贝本地已有的 Python 缓存、adb、ffmpeg 和 WebView2 在线安装器。
macOS、Linux 以后可以在对应函数里补上自己的运行时,其余步骤可以复用。
"""
@@ -31,7 +31,8 @@ PYTHON_EMBED_URL = (
)
GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
FFMPEG_URL = "https://github.com/eugeneware/ffmpeg-static/releases/download/b6.1.1/ffmpeg-win32-x64.gz"
WEBVIEW_INSTALLER = "MicrosoftEdgeWebView2RuntimeInstallerX64.exe"
WEBVIEW_INSTALLER = "MicrosoftEdgeWebview2Setup.exe"
WEBVIEW_BOOTSTRAP_URL = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
def log(message: str) -> None:
@@ -166,7 +167,11 @@ def bundle_webview(stage: Path) -> None:
return
source = ROOT / "vendor" / "webview2" / WEBVIEW_INSTALLER
if not source.is_file():
raise SystemExit(f"vendor/webview2 里没有 {WEBVIEW_INSTALLER}")
download(WEBVIEW_BOOTSTRAP_URL, source)
data = source.read_bytes()[:2]
size = source.stat().st_size
if data != b"MZ" or not 200_000 <= size <= 20_000_000:
raise SystemExit(f"{WEBVIEW_INSTALLER} 不是 WebView2 在线安装器")
dest = stage / "vendor" / "webview2"
dest.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, dest / source.name)