diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-06-30 22:09:26 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-06-30 22:09:26 -0700 | 
| commit | ae32caa515ee6926358118e4a7d40e2e78604b20 (patch) | |
| tree | b1ea5131737a45269a0defe8aaa454c9d4b0fde2 /extension/src | |
| parent | 0d7223825009571f90465af2aa07b99910b86cb0 (diff) | |
| download | sncontinue-ae32caa515ee6926358118e4a7d40e2e78604b20.tar.gz sncontinue-ae32caa515ee6926358118e4a7d40e2e78604b20.tar.bz2 sncontinue-ae32caa515ee6926358118e4a7d40e2e78604b20.zip | |
check for secondary installed python versions
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/activation/environmentSetup.ts | 30 | 
1 files changed, 25 insertions, 5 deletions
| diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 1593153c..d4c81d2e 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -67,17 +67,37 @@ async function getPythonPipCommands() {        vscode.window.showErrorMessage(          "Continue requires Python3. Please install from https://www.python.org/downloads, reload VS Code, and try again."        ); -      throw new Error("Python 3.7 or greater is not installed."); +      throw new Error("Python 3 is not installed.");      }    }    const version = stdout.split(" ")[1];    const [major, minor] = version.split(".");    if (parseInt(major) !== 3 || parseInt(minor) < 7) { -    vscode.window.showErrorMessage( -      "Continue requires Python3 version 3.7 or greater. Please update your Python3 installation, reload VS Code, and try again." -    ); -    throw new Error("Python3 is not installed."); +    // Need to check specific versions +    const checkPython3VersionExists = async (minorVersion: number) => { +      const [stdout, stderr] = await runCommand( +        `python3.${minorVersion} --version` +      ); +      return typeof stderr === "undefined" || stderr === ""; +    }; + +    const validVersions = [7, 8, 9, 10, 11, 12]; +    let versionExists = false; + +    for (const minorVersion of validVersions) { +      if (await checkPython3VersionExists(minorVersion)) { +        versionExists = true; +        break; +      } +    } + +    if (!versionExists) { +      vscode.window.showErrorMessage( +        "Continue requires Python3 version 3.7 or greater. Please update your Python3 installation, reload VS Code, and try again." +      ); +      throw new Error("Python3 is not installed."); +    }    }    const pipCmd = pythonCmd.endsWith("3") ? "pip3" : "pip";    return [pythonCmd, pipCmd]; | 
