's'
This commit is contained in:
@@ -67,7 +67,7 @@ function enableEmbedSitePackages() {
|
||||
const base = f.replace(/\._pth$/, '')
|
||||
const zipLine = `${base}.zip`
|
||||
// 嵌入式解释器必须显式启用 import site,Lib\\site-packages 才会进 sys.path(pip 才能用)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user