mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-17 17:56:46 +00:00
- Added automatic detection of PEP 668 environments - Implemented pipx as preferred installation method for Linux/macOS - Added fallback to pip --user for externally managed environments - Improved error messages with clear installation alternatives - Added --break-system-packages as last resort option - Updated NPM wrapper to handle all installation scenarios - Enhanced update mechanism to detect and use correct tool
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
const { spawnSync } = require("child_process");
|
|
|
|
function run(cmd, args = [], opts = {}) {
|
|
return spawnSync(cmd, args, {
|
|
stdio: opts.stdio || "pipe",
|
|
shell: true
|
|
});
|
|
}
|
|
|
|
function checkCommand(cmd, args = ["--version"]) {
|
|
const result = run(cmd, args);
|
|
return result.status === 0;
|
|
}
|
|
|
|
function detectPython() {
|
|
const candidates = ["python3", "python", "py"];
|
|
for (let c of candidates) {
|
|
if (checkCommand(c)) return c;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function detectPip() {
|
|
const candidates = ["pip3", "pip", "py -m pip"];
|
|
for (let c of candidates) {
|
|
if (checkCommand(c.split(" ")[0])) return c;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function detectPipx() {
|
|
if (checkCommand("pipx")) return "pipx";
|
|
return null;
|
|
}
|
|
|
|
function isSuperClaudeInstalled(pipCmd) {
|
|
const result = run(pipCmd, ["show", "SuperClaude"]);
|
|
return result.status === 0;
|
|
}
|
|
|
|
function isSuperClaudeInstalledPipx() {
|
|
const result = run("pipx", ["list"]);
|
|
if (result.status === 0 && result.stdout) {
|
|
return result.stdout.toString().includes("SuperClaude");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function checkPythonEnvironment() {
|
|
// Check if we're in an externally managed environment (PEP 668)
|
|
const result = run("python3", ["-c", "import sysconfig; print(sysconfig.get_path('stdlib'))"]);
|
|
if (result.status === 0 && result.stdout) {
|
|
const stdlibPath = result.stdout.toString().trim();
|
|
const checkPep668 = run("test", ["-f", `${stdlibPath}/EXTERNALLY-MANAGED`]);
|
|
return checkPep668.status === 0;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
module.exports = { run, detectPython, detectPip, detectPipx, isSuperClaudeInstalled, isSuperClaudeInstalledPipx, checkPythonEnvironment };
|