mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-10-11 09:28:43 +02:00
Merge pull request #308 from BigBodyCobain/fix/296-windows-venv-uvicorn-detection
Fix #296: reject backend venvs missing uvicorn before launch (Windows)
This commit is contained in:
1 file changed
+9
-2
+9
-2
@@ -76,6 +76,13 @@ function canRun(command, args) {
|
|||||||
return !result.error && result.status === 0;
|
return !result.error && result.status === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canRunBackendPython(pythonBin) {
|
||||||
|
return (
|
||||||
|
canRun(pythonBin, ["-V"]) &&
|
||||||
|
canRun(pythonBin, ["-c", "import fastapi, uvicorn"])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function findBasePython() {
|
function findBasePython() {
|
||||||
const candidates = isWindows
|
const candidates = isWindows
|
||||||
? [
|
? [
|
||||||
@@ -135,12 +142,12 @@ function rebuildBackendVenv(targetDir, basePython) {
|
|||||||
if (result.error || result.status !== 0) {
|
if (result.error || result.status !== 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return canRun(repairedBin, ["-V"]) ? repairedBin : null;
|
return canRunBackendPython(repairedBin) ? repairedBin : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureBackendVenv() {
|
function ensureBackendVenv() {
|
||||||
for (const candidate of venvCandidates) {
|
for (const candidate of venvCandidates) {
|
||||||
if (fs.existsSync(candidate) && canRun(candidate, ["-V"])) {
|
if (fs.existsSync(candidate) && canRunBackendPython(candidate)) {
|
||||||
persistSelectedVenv(candidate);
|
persistSelectedVenv(candidate);
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user