diff --git a/.gitignore b/.gitignore index 34c6b93..675f3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules dist yarn.lock package-lock.json +platformio-node-helpers-11.3.0.tgz diff --git a/src/installer/get-python.js b/src/installer/get-python.js index 85cf046..abac2a9 100644 --- a/src/installer/get-python.js +++ b/src/installer/get-python.js @@ -104,7 +104,8 @@ jjxDah2nGN59PRbxYvnKkKj9 -----END CERTIFICATE----- `; -export async function findPythonExecutable() { +export async function findPythonExecutable(options = {}) { + const maxPythonVersion = options.maxPythonVersion || process.env.PLATFORMIO_MAX_PYTHON_VERSION || '3.13'; const exenames = proc.IS_WINDOWS ? ['python.exe'] : ['python3', 'python']; const envPath = process.env.PLATFORMIO_PATH || process.env.PATH; const errors = []; @@ -116,6 +117,20 @@ export async function findPythonExecutable() { fs.existsSync(executable) && (await callInstallerScript(executable, ['check', 'python'])) ) { + // Verify Python version does not exceed maximum stable baseline + try { + const versionCheck = await proc.getCommandOutput(executable, [ + '-c', + `import sys; print("1" if sys.version_info < tuple(map(int, "${maxPythonVersion}".split("."))) else "0")` + ]); + if (versionCheck.trim() !== '1') { + console.warn(`Python at ${executable} exceeds max supported version (>= ${maxPythonVersion})`); + continue; // Reject bleeding edge and force fallback loop + } + } catch (err) { + console.warn(`Failed to verify Python version structure for ${executable}:`, err); + continue; + } return executable; } } catch (err) {