fix: vendor wcf python deps for isolated profile

This commit is contained in:
Codex
2026-06-13 16:43:39 +00:00
parent 3b6d22d817
commit 1e9245e60d
3 changed files with 18 additions and 4 deletions
+11 -3
View File
@@ -6,6 +6,7 @@ $ExtractRoot = Join-Path $Root "wechat-3.9.12.51-extracted"
$VersionRoot = Join-Path $ExtractRoot "[3.9.12.51]" $VersionRoot = Join-Path $ExtractRoot "[3.9.12.51]"
$DataRoot = Join-Path $Root "data\profile" $DataRoot = Join-Path $Root "data\profile"
$WcfRoot = Join-Path $Root "wcf\v39.5.2" $WcfRoot = Join-Path $Root "wcf\v39.5.2"
$PythonSite = Join-Path $WcfRoot "python-site"
$StateRoot = Join-Path $Root "wcf-state" $StateRoot = Join-Path $Root "wcf-state"
$DownloadRoot = Join-Path $Root "downloads" $DownloadRoot = Join-Path $Root "downloads"
$PrepareResult = Join-Path $StateRoot "prepare-result.json" $PrepareResult = Join-Path $StateRoot "prepare-result.json"
@@ -15,7 +16,7 @@ $PipIndex = "http://mirrors.aliyun.com/pypi/simple/"
$ReleaseBase = "https://github.com/lich0821/WeChatFerry/releases/download/v39.5.2" $ReleaseBase = "https://github.com/lich0821/WeChatFerry/releases/download/v39.5.2"
$RegistryPath = "HKCU:\Software\Tencent\WeChat" $RegistryPath = "HKCU:\Software\Tencent\WeChat"
New-Item -ItemType Directory -Force $WechatRoot,$ExtractRoot,$VersionRoot,$DataRoot,$WcfRoot,$StateRoot,$DownloadRoot | Out-Null New-Item -ItemType Directory -Force $WechatRoot,$ExtractRoot,$VersionRoot,$DataRoot,$WcfRoot,$PythonSite,$StateRoot,$DownloadRoot | Out-Null
$StartedAt = (Get-Date).ToUniversalTime().ToString("o") $StartedAt = (Get-Date).ToUniversalTime().ToString("o")
function Write-PrepareProgress { function Write-PrepareProgress {
@@ -124,7 +125,7 @@ function Install-Wcferry {
$pipOut = Join-Path $StateRoot "prepare-pip.stdout.log" $pipOut = Join-Path $StateRoot "prepare-pip.stdout.log"
$pipErr = Join-Path $StateRoot "prepare-pip.stderr.log" $pipErr = Join-Path $StateRoot "prepare-pip.stderr.log"
Write-PrepareProgress "pip-install-start" Write-PrepareProgress "pip-install-start"
& $Python -m pip install --trusted-host mirrors.aliyun.com --index-url $PipIndex --timeout 120 --retries 8 "wcferry==39.5.2.0" > $pipOut 2> $pipErr & $Python -m pip install --upgrade --target $PythonSite --trusted-host mirrors.aliyun.com --index-url $PipIndex --timeout 120 --retries 8 "wcferry==39.5.2.0" > $pipOut 2> $pipErr
if ($LASTEXITCODE -ne 0) { throw "pip install wcferry failed; see $pipErr" } if ($LASTEXITCODE -ne 0) { throw "pip install wcferry failed; see $pipErr" }
Write-PrepareProgress "pip-install-done" Write-PrepareProgress "pip-install-done"
@@ -142,7 +143,13 @@ payload = {
} }
print(json.dumps(payload, ensure_ascii=False)) print(json.dumps(payload, ensure_ascii=False))
'@ | Set-Content -Encoding utf8 $probePy '@ | Set-Content -Encoding utf8 $probePy
$pyProbe = (& $Python $probePy) | ConvertFrom-Json $oldPythonPath = $env:PYTHONPATH
try {
$env:PYTHONPATH = if ($oldPythonPath) { "$PythonSite;$oldPythonPath" } else { $PythonSite }
$pyProbe = (& $Python $probePy) | ConvertFrom-Json
} finally {
$env:PYTHONPATH = $oldPythonPath
}
return [ordered]@{ return [ordered]@{
ok = [bool]$pyProbe.ok ok = [bool]$pyProbe.ok
version = $pyProbe.wcferryVersion version = $pyProbe.wcferryVersion
@@ -231,6 +238,7 @@ $summary = [ordered]@{
requiredVersion = "3.9.12.51" requiredVersion = "3.9.12.51"
profile = $profile profile = $profile
wcfRoot = $WcfRoot wcfRoot = $WcfRoot
pythonSite = $PythonSite
stateRoot = $StateRoot stateRoot = $StateRoot
python = $Python python = $Python
wcferryVersion = $wcferry.version wcferryVersion = $wcferry.version
+5 -1
View File
@@ -2,6 +2,7 @@ $ErrorActionPreference = "Stop"
$Root = "C:\UniDesk\personal-wechat" $Root = "C:\UniDesk\personal-wechat"
$WcfRoot = Join-Path $Root "wcf\v39.5.2" $WcfRoot = Join-Path $Root "wcf\v39.5.2"
$PythonSite = Join-Path $WcfRoot "python-site"
$StateRoot = Join-Path $Root "wcf-state" $StateRoot = Join-Path $Root "wcf-state"
$DataRoot = Join-Path $Root "data\profile" $DataRoot = Join-Path $Root "data\profile"
$AppData = Join-Path $DataRoot "AppData\Roaming" $AppData = Join-Path $DataRoot "AppData\Roaming"
@@ -15,7 +16,7 @@ $Stdout = Join-Path $StateRoot "wcf-host.stdout.log"
$Stderr = Join-Path $StateRoot "wcf-host.stderr.log" $Stderr = Join-Path $StateRoot "wcf-host.stderr.log"
$Runner = Join-Path $StateRoot "wcf-host-runner.cmd" $Runner = Join-Path $StateRoot "wcf-host-runner.cmd"
New-Item -ItemType Directory -Force $StateRoot,$DataRoot,$AppData,$LocalAppData,$Documents,$TempRoot | Out-Null New-Item -ItemType Directory -Force $StateRoot,$DataRoot,$AppData,$LocalAppData,$Documents,$TempRoot,$PythonSite | Out-Null
function Get-WcfProcessByPidFile { function Get-WcfProcessByPidFile {
if (!(Test-Path -LiteralPath $PidFile)) { return $null } if (!(Test-Path -LiteralPath $PidFile)) { return $null }
@@ -53,11 +54,13 @@ Start-Sleep -Seconds 2
Remove-Item -Force (Join-Path $StateRoot "status.json") -ErrorAction SilentlyContinue Remove-Item -Force (Join-Path $StateRoot "status.json") -ErrorAction SilentlyContinue
Remove-Item -Force (Join-Path $WcfRoot "injector.log") -ErrorAction SilentlyContinue Remove-Item -Force (Join-Path $WcfRoot "injector.log") -ErrorAction SilentlyContinue
Remove-Item -Force $PidFile -ErrorAction SilentlyContinue
@" @"
@echo off @echo off
set WCF_COMMAND_PORT=10086 set WCF_COMMAND_PORT=10086
set WCF_STATE_ROOT=$StateRoot set WCF_STATE_ROOT=$StateRoot
set PYTHONPATH=$PythonSite
set USERPROFILE=$DataRoot set USERPROFILE=$DataRoot
set APPDATA=$AppData set APPDATA=$AppData
set LOCALAPPDATA=$LocalAppData set LOCALAPPDATA=$LocalAppData
@@ -88,6 +91,7 @@ if (Test-Path -LiteralPath $PidFile) {
stderr = $Stderr stderr = $Stderr
status = (Join-Path $StateRoot "status.json") status = (Join-Path $StateRoot "status.json")
dataRoot = $DataRoot dataRoot = $DataRoot
pythonSite = $PythonSite
appData = $AppData appData = $AppData
localAppData = $LocalAppData localAppData = $LocalAppData
} | ConvertTo-Json -Depth 6 } | ConvertTo-Json -Depth 6
@@ -2,6 +2,7 @@ $ErrorActionPreference = "Continue"
$Root = "C:\UniDesk\personal-wechat" $Root = "C:\UniDesk\personal-wechat"
$WcfRoot = Join-Path $Root "wcf\v39.5.2" $WcfRoot = Join-Path $Root "wcf\v39.5.2"
$PythonSite = Join-Path $WcfRoot "python-site"
$StateRoot = Join-Path $Root "wcf-state" $StateRoot = Join-Path $Root "wcf-state"
$DataRoot = Join-Path $Root "data\profile" $DataRoot = Join-Path $Root "data\profile"
$PidFile = Join-Path $StateRoot "wcf-host.pid" $PidFile = Join-Path $StateRoot "wcf-host.pid"
@@ -81,6 +82,7 @@ $personalProcesses = Get-CimInstance Win32_Process -ErrorAction SilentlyContinue
paths = [ordered]@{ paths = [ordered]@{
root = $Root root = $Root
dataRoot = $DataRoot dataRoot = $DataRoot
pythonSite = $PythonSite
stateRoot = $StateRoot stateRoot = $StateRoot
statusFile = $StatusFile statusFile = $StatusFile
prepareResultFile = $PrepareResultFile prepareResultFile = $PrepareResultFile