fix: vendor wcf python deps for isolated profile
This commit is contained in:
@@ -6,6 +6,7 @@ $ExtractRoot = Join-Path $Root "wechat-3.9.12.51-extracted"
|
||||
$VersionRoot = Join-Path $ExtractRoot "[3.9.12.51]"
|
||||
$DataRoot = Join-Path $Root "data\profile"
|
||||
$WcfRoot = Join-Path $Root "wcf\v39.5.2"
|
||||
$PythonSite = Join-Path $WcfRoot "python-site"
|
||||
$StateRoot = Join-Path $Root "wcf-state"
|
||||
$DownloadRoot = Join-Path $Root "downloads"
|
||||
$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"
|
||||
$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")
|
||||
|
||||
function Write-PrepareProgress {
|
||||
@@ -124,7 +125,7 @@ function Install-Wcferry {
|
||||
$pipOut = Join-Path $StateRoot "prepare-pip.stdout.log"
|
||||
$pipErr = Join-Path $StateRoot "prepare-pip.stderr.log"
|
||||
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" }
|
||||
Write-PrepareProgress "pip-install-done"
|
||||
|
||||
@@ -142,7 +143,13 @@ payload = {
|
||||
}
|
||||
print(json.dumps(payload, ensure_ascii=False))
|
||||
'@ | Set-Content -Encoding utf8 $probePy
|
||||
$oldPythonPath = $env:PYTHONPATH
|
||||
try {
|
||||
$env:PYTHONPATH = if ($oldPythonPath) { "$PythonSite;$oldPythonPath" } else { $PythonSite }
|
||||
$pyProbe = (& $Python $probePy) | ConvertFrom-Json
|
||||
} finally {
|
||||
$env:PYTHONPATH = $oldPythonPath
|
||||
}
|
||||
return [ordered]@{
|
||||
ok = [bool]$pyProbe.ok
|
||||
version = $pyProbe.wcferryVersion
|
||||
@@ -231,6 +238,7 @@ $summary = [ordered]@{
|
||||
requiredVersion = "3.9.12.51"
|
||||
profile = $profile
|
||||
wcfRoot = $WcfRoot
|
||||
pythonSite = $PythonSite
|
||||
stateRoot = $StateRoot
|
||||
python = $Python
|
||||
wcferryVersion = $wcferry.version
|
||||
|
||||
@@ -2,6 +2,7 @@ $ErrorActionPreference = "Stop"
|
||||
|
||||
$Root = "C:\UniDesk\personal-wechat"
|
||||
$WcfRoot = Join-Path $Root "wcf\v39.5.2"
|
||||
$PythonSite = Join-Path $WcfRoot "python-site"
|
||||
$StateRoot = Join-Path $Root "wcf-state"
|
||||
$DataRoot = Join-Path $Root "data\profile"
|
||||
$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"
|
||||
$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 {
|
||||
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 $WcfRoot "injector.log") -ErrorAction SilentlyContinue
|
||||
Remove-Item -Force $PidFile -ErrorAction SilentlyContinue
|
||||
|
||||
@"
|
||||
@echo off
|
||||
set WCF_COMMAND_PORT=10086
|
||||
set WCF_STATE_ROOT=$StateRoot
|
||||
set PYTHONPATH=$PythonSite
|
||||
set USERPROFILE=$DataRoot
|
||||
set APPDATA=$AppData
|
||||
set LOCALAPPDATA=$LocalAppData
|
||||
@@ -88,6 +91,7 @@ if (Test-Path -LiteralPath $PidFile) {
|
||||
stderr = $Stderr
|
||||
status = (Join-Path $StateRoot "status.json")
|
||||
dataRoot = $DataRoot
|
||||
pythonSite = $PythonSite
|
||||
appData = $AppData
|
||||
localAppData = $LocalAppData
|
||||
} | ConvertTo-Json -Depth 6
|
||||
|
||||
@@ -2,6 +2,7 @@ $ErrorActionPreference = "Continue"
|
||||
|
||||
$Root = "C:\UniDesk\personal-wechat"
|
||||
$WcfRoot = Join-Path $Root "wcf\v39.5.2"
|
||||
$PythonSite = Join-Path $WcfRoot "python-site"
|
||||
$StateRoot = Join-Path $Root "wcf-state"
|
||||
$DataRoot = Join-Path $Root "data\profile"
|
||||
$PidFile = Join-Path $StateRoot "wcf-host.pid"
|
||||
@@ -81,6 +82,7 @@ $personalProcesses = Get-CimInstance Win32_Process -ErrorAction SilentlyContinue
|
||||
paths = [ordered]@{
|
||||
root = $Root
|
||||
dataRoot = $DataRoot
|
||||
pythonSite = $PythonSite
|
||||
stateRoot = $StateRoot
|
||||
statusFile = $StatusFile
|
||||
prepareResultFile = $PrepareResultFile
|
||||
|
||||
Reference in New Issue
Block a user