@@ -9,6 +9,23 @@ const extend = require('util')._extend // eslint-disable-line
99const win = process . platform === 'win32'
1010const logWithPrefix = require ( './util' ) . logWithPrefix
1111
12+ const systemDrive = process . env . SystemDrive || 'C:'
13+ const username = process . env . USERNAME || process . env . USER || require ( 'os' ) . userInfo ( ) . username
14+ const localAppData = process . env . LOCALAPPDATA || `${ systemDrive } \\${ username } \\AppData\\Local`
15+ const programFiles = process . env . ProgramW6432 || process . env . ProgramFiles || `${ systemDrive } \\Program Files`
16+ const programFilesX86 = process . env [ 'ProgramFiles(x86)' ] || `${ programFiles } (x86)`
17+
18+ const winDefaultLocationsArray = [ ]
19+ for ( const majorMinor of [ '39' , '38' , '37' , '36' ] ) {
20+ winDefaultLocationsArray . push (
21+ `${ localAppData } \\Programs\\Python\\Python${ majorMinor } \\python.exe` ,
22+ `${ programFiles } \\Python${ majorMinor } \\python.exe` ,
23+ `${ localAppData } \\Programs\\Python\\Python${ majorMinor } -32\\python.exe` ,
24+ `${ programFiles } \\Python${ majorMinor } -32\\python.exe` ,
25+ `${ programFilesX86 } \\Python${ majorMinor } -32\\python.exe`
26+ )
27+ }
28+
1229//! after editing file don't forget run "npm test" and
1330//! change tests for this file if needed
1431
@@ -70,17 +87,14 @@ class PythonFinder {
7087 // for testing
7188 // 'print("2.1.1")'
7289 ]
73- this . semverRange = '2.7.x || >=3.5 .0'
90+ this . semverRange = '>=3.6 .0'
7491
7592 // These can be overridden for testing:
7693 this . execFile = cp . execFile
7794 this . env = process . env
7895 this . win = win
7996 this . pyLauncher = 'py.exe'
80- this . winDefaultLocations = [
81- path . join ( process . env . SystemDrive || 'C:' , 'Python37' , 'python.exe' ) ,
82- path . join ( process . env . SystemDrive || 'C:' , 'Python27' , 'python.exe' )
83- ]
97+ this . winDefaultLocations = winDefaultLocationsArray
8498 }
8599
86100 /**
@@ -200,11 +214,6 @@ class PythonFinder {
200214 checkFunc : this . checkCommand ,
201215 name : 'python' ,
202216 arg : 'python'
203- } ,
204- {
205- checkFunc : this . checkCommand ,
206- name : 'python2' ,
207- arg : 'python2'
208217 }
209218 ]
210219
@@ -227,7 +236,7 @@ class PythonFinder {
227236 `checking if the ${ colorizeOutput (
228237 GREEN ,
229238 'py launcher'
230- ) } can be used to find Python`
239+ ) } can be used to find Python 3 `
231240 )
232241 } ,
233242 checkFunc : this . checkPyLauncher ,
@@ -620,7 +629,7 @@ function findPython (configPython, callback) {
620629/* findPython(null, (err, found) => {
621630 console.log('found:', '\x1b[31m', found)
622631 console.log('\x1b[0m')
623- })
632+ })
624633*/
625634module . exports = findPython
626635module . exports . test = {
0 commit comments