Skip to content

Commit f6cfa6e

Browse files
author
Kartik Raj
authored
Remove old code for folder support in interpreter path setting (#22413)
Closes #12452
1 parent 32ea534 commit f6cfa6e

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

src/client/common/configSettings.ts

+1-64
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
// eslint-disable-next-line camelcase
44
import * as path from 'path';
5-
import * as fs from 'fs';
65
import {
76
ConfigurationChangeEvent,
87
ConfigurationTarget,
@@ -35,8 +34,6 @@ import {
3534
} from './types';
3635
import { debounceSync } from './utils/decorators';
3736
import { SystemVariables } from './variables/systemVariables';
38-
import { getOSType, OSType } from './utils/platform';
39-
import { isWindows } from './platform/platformService';
4037

4138
const untildify = require('untildify');
4239

@@ -390,7 +387,7 @@ export class PythonSettings implements IPythonSettings {
390387

391388
// eslint-disable-next-line class-methods-use-this
392389
protected getPythonExecutable(pythonPath: string): string {
393-
return getPythonExecutable(pythonPath);
390+
return untildify(pythonPath);
394391
}
395392

396393
protected onWorkspaceFoldersChanged(): void {
@@ -489,63 +486,3 @@ function getAbsolutePath(pathToCheck: string, rootDir: string | undefined): stri
489486
}
490487
return path.isAbsolute(pathToCheck) ? pathToCheck : path.resolve(rootDir, pathToCheck);
491488
}
492-
493-
function getPythonExecutable(pythonPath: string): string {
494-
pythonPath = untildify(pythonPath) as string;
495-
496-
// If only 'python'.
497-
if (
498-
pythonPath === 'python' ||
499-
pythonPath.indexOf(path.sep) === -1 ||
500-
path.basename(pythonPath) === path.dirname(pythonPath)
501-
) {
502-
return pythonPath;
503-
}
504-
505-
if (isValidPythonPath(pythonPath)) {
506-
return pythonPath;
507-
}
508-
// Keep python right on top, for backwards compatibility.
509-
510-
const KnownPythonExecutables = [
511-
'python',
512-
'python4',
513-
'python3.6',
514-
'python3.5',
515-
'python3',
516-
'python2.7',
517-
'python2',
518-
'python3.7',
519-
'python3.8',
520-
'python3.9',
521-
];
522-
523-
for (let executableName of KnownPythonExecutables) {
524-
// Suffix with 'python' for linux and 'osx', and 'python.exe' for 'windows'.
525-
if (isWindows()) {
526-
executableName = `${executableName}.exe`;
527-
if (isValidPythonPath(path.join(pythonPath, executableName))) {
528-
return path.join(pythonPath, executableName);
529-
}
530-
if (isValidPythonPath(path.join(pythonPath, 'Scripts', executableName))) {
531-
return path.join(pythonPath, 'Scripts', executableName);
532-
}
533-
} else {
534-
if (isValidPythonPath(path.join(pythonPath, executableName))) {
535-
return path.join(pythonPath, executableName);
536-
}
537-
if (isValidPythonPath(path.join(pythonPath, 'bin', executableName))) {
538-
return path.join(pythonPath, 'bin', executableName);
539-
}
540-
}
541-
}
542-
543-
return pythonPath;
544-
}
545-
546-
function isValidPythonPath(pythonPath: string): boolean {
547-
return (
548-
fs.existsSync(pythonPath) &&
549-
path.basename(getOSType() === OSType.Windows ? pythonPath.toLowerCase() : pythonPath).startsWith('python')
550-
);
551-
}

0 commit comments

Comments
 (0)