From 0e167016b072d39c04289ef750fb7d26746a12ee Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 2 Nov 2023 19:58:22 +0000 Subject: [PATCH 1/2] Remove old code for folder support in interpreter path setting --- src/client/common/configSettings.ts | 62 +---------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index f9c56d4992fe..be1d6407dacb 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -390,7 +390,7 @@ export class PythonSettings implements IPythonSettings { // eslint-disable-next-line class-methods-use-this protected getPythonExecutable(pythonPath: string): string { - return getPythonExecutable(pythonPath); + return untildify(pythonPath); } protected onWorkspaceFoldersChanged(): void { @@ -489,63 +489,3 @@ function getAbsolutePath(pathToCheck: string, rootDir: string | undefined): stri } return path.isAbsolute(pathToCheck) ? pathToCheck : path.resolve(rootDir, pathToCheck); } - -function getPythonExecutable(pythonPath: string): string { - pythonPath = untildify(pythonPath) as string; - - // If only 'python'. - if ( - pythonPath === 'python' || - pythonPath.indexOf(path.sep) === -1 || - path.basename(pythonPath) === path.dirname(pythonPath) - ) { - return pythonPath; - } - - if (isValidPythonPath(pythonPath)) { - return pythonPath; - } - // Keep python right on top, for backwards compatibility. - - const KnownPythonExecutables = [ - 'python', - 'python4', - 'python3.6', - 'python3.5', - 'python3', - 'python2.7', - 'python2', - 'python3.7', - 'python3.8', - 'python3.9', - ]; - - for (let executableName of KnownPythonExecutables) { - // Suffix with 'python' for linux and 'osx', and 'python.exe' for 'windows'. - if (isWindows()) { - executableName = `${executableName}.exe`; - if (isValidPythonPath(path.join(pythonPath, executableName))) { - return path.join(pythonPath, executableName); - } - if (isValidPythonPath(path.join(pythonPath, 'Scripts', executableName))) { - return path.join(pythonPath, 'Scripts', executableName); - } - } else { - if (isValidPythonPath(path.join(pythonPath, executableName))) { - return path.join(pythonPath, executableName); - } - if (isValidPythonPath(path.join(pythonPath, 'bin', executableName))) { - return path.join(pythonPath, 'bin', executableName); - } - } - } - - return pythonPath; -} - -function isValidPythonPath(pythonPath: string): boolean { - return ( - fs.existsSync(pythonPath) && - path.basename(getOSType() === OSType.Windows ? pythonPath.toLowerCase() : pythonPath).startsWith('python') - ); -} From 1a59a31b7f8e9d6823a8b88adb219ab6b3d2fedd Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 2 Nov 2023 20:00:01 +0000 Subject: [PATCH 2/2] remove import --- src/client/common/configSettings.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index be1d6407dacb..3fc98702f659 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -2,7 +2,6 @@ // eslint-disable-next-line camelcase import * as path from 'path'; -import * as fs from 'fs'; import { ConfigurationChangeEvent, ConfigurationTarget, @@ -35,8 +34,6 @@ import { } from './types'; import { debounceSync } from './utils/decorators'; import { SystemVariables } from './variables/systemVariables'; -import { getOSType, OSType } from './utils/platform'; -import { isWindows } from './platform/platformService'; const untildify = require('untildify');