mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
fix(python): improve Python detection and pip command reliability
- Add shared python-utils.ts module for consistent Python detection - Use `python -m pip` instead of direct pip command (fixes "pip not found") - Support CCW_PYTHON env var for custom Python path - Use Windows py launcher to find compatible versions (3.9-3.12) - Warn users when Python version may not be compatible with onnxruntime Fixes issues where users couldn't install ccw-litellm due to: - pip not in PATH - Only pip3 available (not pip) - Python 3.13+ without onnxruntime support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import { existsSync, mkdirSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
import { homedir } from 'os';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { getSystemPython } from '../utils/python-utils.js';
|
||||
|
||||
// Get directory of this module
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
@@ -131,25 +132,7 @@ function clearVenvStatusCache(): void {
|
||||
venvStatusCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect available Python 3 executable
|
||||
* @returns Python executable command
|
||||
*/
|
||||
function getSystemPython(): string {
|
||||
const commands = process.platform === 'win32' ? ['python', 'py', 'python3'] : ['python3', 'python'];
|
||||
|
||||
for (const cmd of commands) {
|
||||
try {
|
||||
const version = execSync(`${cmd} --version 2>&1`, { encoding: 'utf8' });
|
||||
if (version.includes('Python 3')) {
|
||||
return cmd;
|
||||
}
|
||||
} catch {
|
||||
// Try next command
|
||||
}
|
||||
}
|
||||
throw new Error('Python 3 not found. Please install Python 3 and ensure it is in PATH.');
|
||||
}
|
||||
// Python detection functions imported from ../utils/python-utils.js
|
||||
|
||||
/**
|
||||
* Check if CodexLens venv exists and has required packages
|
||||
|
||||
Reference in New Issue
Block a user