fix: accept Python 3.12+ in install-backend.js (#443)

* fix: accept Python 3.12+ in install-backend.js

The installer was only accepting Python 3.12 exactly. This caused issues
for users with Python 3.13 or 3.14 installed, as it would fall back to
any available python binary and fail version requirements.

Changes:
- Accept Python 3.12, 3.13, and 3.14
- Prefer newer versions first (3.14 → 3.13 → 3.12)
- Update error message to say "3.12+" instead of "3.12"

Fixes #440

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Abe Diaz (@abe238) <abe238@gmail.com>

* refactor: use proper version parsing for Python detection

Address code review feedback from Gemini and CodeRabbit:
- Replace string matching with regex version parsing for robustness
- Handles pre-release versions (3.12rc1, 3.13.0a1) correctly
- Future-proof for Python 3.15+ without code changes
- Update comment from "Python 3.12" to "Python 3.12+"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Abe Diaz (@abe238) <abe238@gmail.com>

---------

Signed-off-by: Abe Diaz (@abe238) <abe238@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Abe Diaz (@abe238)
2025-12-31 01:41:16 -08:00
committed by GitHub
parent 203a970ab5
commit c15bb31146
+17 -9
View File
@@ -26,11 +26,11 @@ function run(cmd, options = {}) {
}
}
// Find Python 3.12
// Find Python 3.12+
function findPython() {
const candidates = isWindows
? ['py -3.12', 'python3.12', 'python']
: ['python3.12', 'python3', 'python'];
? ['py -3.14', 'py -3.13', 'py -3.12', 'python3.14', 'python3.13', 'python3.12', 'python3', 'python']
: ['python3.14', 'python3.13', 'python3.12', 'python3', 'python'];
for (const cmd of candidates) {
try {
@@ -38,9 +38,17 @@ function findPython() {
encoding: 'utf8',
shell: true,
});
if (result.status === 0 && result.stdout.includes('3.12')) {
console.log(`Found Python 3.12: ${cmd} -> ${result.stdout.trim()}`);
return cmd;
// Accept Python 3.12+ using proper version parsing
if (result.status === 0) {
const versionMatch = result.stdout.match(/Python (\d+)\.(\d+)/);
if (versionMatch) {
const major = parseInt(versionMatch[1], 10);
const minor = parseInt(versionMatch[2], 10);
if (major === 3 && minor >= 12) {
console.log(`Found Python 3.12+: ${cmd} -> ${result.stdout.trim()}`);
return cmd;
}
}
}
} catch (e) {
// Continue to next candidate
@@ -58,11 +66,11 @@ function getPipPath() {
// Main installation
async function main() {
// Check for Python 3.12
// Check for Python 3.12+
const python = findPython();
if (!python) {
console.error('\nError: Python 3.12 is required but not found.');
console.error('Please install Python 3.12:');
console.error('\nError: Python 3.12+ is required but not found.');
console.error('Please install Python 3.12 or higher:');
if (isWindows) {
console.error(' winget install Python.Python.3.12');
} else if (os.platform() === 'darwin') {