()
| 38 | * @returns The detected package manager, or null if none found |
| 39 | */ |
| 40 | export async function detectPythonPackageManager(): Promise<PythonPackageManager | null> { |
| 41 | // Check uv first (preferred for isolated environments) |
| 42 | // We check for 'uv' since 'uv tool install' is the install command |
| 43 | const uvResult = await execFileNoThrow('which', ['uv']) |
| 44 | if (uvResult.code === 0) { |
| 45 | logForDebugging('[it2Setup] Found uv (will use uv tool install)') |
| 46 | return 'uvx' // Keep the type name for compatibility |
| 47 | } |
| 48 | |
| 49 | // Check pipx (good for isolated environments) |
| 50 | const pipxResult = await execFileNoThrow('which', ['pipx']) |
| 51 | if (pipxResult.code === 0) { |
| 52 | logForDebugging('[it2Setup] Found pipx package manager') |
| 53 | return 'pipx' |
| 54 | } |
| 55 | |
| 56 | // Check pip (fallback) |
| 57 | const pipResult = await execFileNoThrow('which', ['pip']) |
| 58 | if (pipResult.code === 0) { |
| 59 | logForDebugging('[it2Setup] Found pip package manager') |
| 60 | return 'pip' |
| 61 | } |
| 62 | |
| 63 | // Also check pip3 |
| 64 | const pip3Result = await execFileNoThrow('which', ['pip3']) |
| 65 | if (pip3Result.code === 0) { |
| 66 | logForDebugging('[it2Setup] Found pip3 package manager') |
| 67 | return 'pip' |
| 68 | } |
| 69 | |
| 70 | logForDebugging('[it2Setup] No Python package manager found') |
| 71 | return null |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Checks if the it2 CLI tool is installed and accessible. |
no test coverage detected