|
2 | 2 |
|
3 | 3 | // eslint-disable-next-line camelcase
|
4 | 4 | import * as path from 'path';
|
5 |
| -import * as fs from 'fs'; |
6 | 5 | import {
|
7 | 6 | ConfigurationChangeEvent,
|
8 | 7 | ConfigurationTarget,
|
@@ -35,8 +34,6 @@ import {
|
35 | 34 | } from './types';
|
36 | 35 | import { debounceSync } from './utils/decorators';
|
37 | 36 | import { SystemVariables } from './variables/systemVariables';
|
38 |
| -import { getOSType, OSType } from './utils/platform'; |
39 |
| -import { isWindows } from './platform/platformService'; |
40 | 37 |
|
41 | 38 | const untildify = require('untildify');
|
42 | 39 |
|
@@ -390,7 +387,7 @@ export class PythonSettings implements IPythonSettings {
|
390 | 387 |
|
391 | 388 | // eslint-disable-next-line class-methods-use-this
|
392 | 389 | protected getPythonExecutable(pythonPath: string): string {
|
393 |
| - return getPythonExecutable(pythonPath); |
| 390 | + return untildify(pythonPath); |
394 | 391 | }
|
395 | 392 |
|
396 | 393 | protected onWorkspaceFoldersChanged(): void {
|
@@ -489,63 +486,3 @@ function getAbsolutePath(pathToCheck: string, rootDir: string | undefined): stri
|
489 | 486 | }
|
490 | 487 | return path.isAbsolute(pathToCheck) ? pathToCheck : path.resolve(rootDir, pathToCheck);
|
491 | 488 | }
|
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