Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 3912666

Browse files
Merge pull request #201 from XortexAI/feature/Local-Setup
Feature/local setup
2 parents 9bf030d + d52642d commit 3912666

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

‎scripts/xmem.js‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,33 @@ function ensurePrerequisites(skipPython = false) {
519519
}
520520
}
521521

522+
function pythonHasPip(pythonPath) {
523+
return run(pythonPath, ["-m", "pip", "--version"], { capture: true, allowFailure: true }).status === 0;
524+
}
525+
526+
function ensureVirtualenv() {
527+
const venvPython = venvPythonPath();
528+
if (!fs.existsSync(venvPython)) {
529+
log("Creating XMem virtualenv");
530+
run(systemPythonCommand(), ["-m", "venv", path.join(root, ".venv")]);
531+
}
532+
533+
if (!pythonHasPip(venvPython)) {
534+
log("Repairing XMem virtualenv pip");
535+
const result = run(venvPython, ["-m", "ensurepip", "--upgrade"], {
536+
allowFailure: true,
537+
});
538+
if (result.status !== 0 || !pythonHasPip(venvPython)) {
539+
fail(
540+
"XMem virtualenv was created, but pip is unavailable. Reinstall Python with venv/pip support, delete .venv, and rerun npm run setup.",
541+
2,
542+
);
543+
}
544+
}
545+
546+
return venvPython;
547+
}
548+
522549
function setupLooksComplete(reposDir) {
523550
return (
524551
fs.existsSync(path.join(root, "pyproject.toml")) &&
@@ -586,11 +613,7 @@ function runSetup(args) {
586613
}
587614

588615
if (!options.skipPythonInstall) {
589-
const venvPython = venvPythonPath();
590-
if (!fs.existsSync(venvPython)) {
591-
log("Creating XMem virtualenv");
592-
run(systemPythonCommand(), ["-m", "venv", path.join(root, ".venv")]);
593-
}
616+
const venvPython = ensureVirtualenv();
594617
log("Installing XMem local dependencies");
595618
run(venvPython, ["-m", "pip", "install", "--upgrade", "pip"]);
596619
run(venvPython, ["-m", "pip", "install", "-e", `${root}[local,dev]`]);

0 commit comments

Comments
 (0)