This commit is contained in:
eric
2026-05-20 23:50:43 -05:00
parent 882ea9268c
commit e6e4f7a02e
17 changed files with 570 additions and 188 deletions

View File

@@ -67,7 +67,7 @@ function enableEmbedSitePackages() {
const base = f.replace(/\._pth$/, '')
const zipLine = `${base}.zip`
// 嵌入式解释器必须显式启用 import siteLib\\site-packages 才会进 sys.pathpip 才能用)
fs.writeFileSync(p, `${zipLine}\n.\n\nimport site\n`, 'utf8')
fs.writeFileSync(p, `${zipLine}\n.\n..\n\nimport site\n`, 'utf8')
}
}
@@ -75,12 +75,20 @@ function hasWorkingEmbedPython() {
if (!fs.existsSync(embedExe)) return false
if (fs.existsSync(path.join(runtimeDir, 'pyvenv.cfg'))) return false
if (fs.existsSync(path.join(runtimeDir, 'Scripts', 'python.exe'))) return false
const r = spawnSync(embedExe, ['-c', 'import fastapi,uvicorn,requests,psutil'], {
cwd: backendRoot,
encoding: 'utf8',
windowsHide: true,
timeout: 60000,
})
enableEmbedSitePackages()
const r = spawnSync(
embedExe,
[
'-c',
'import importlib.util,fastapi,uvicorn,requests,psutil,src; assert importlib.util.find_spec("web2")',
],
{
cwd: backendRoot,
encoding: 'utf8',
windowsHide: true,
timeout: 60000,
},
)
return r.status === 0
}