Skip to content

Commit aa1d795

Browse files
lib: find python checks order changed on windows
These changes favor py launcher over other checks excluding command line or npm configuration and environment variable checks. Also, updated supported python versions list. Fixes: #2871
1 parent 33391db commit aa1d795

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/find-python.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const programFiles = process.env.ProgramW6432 || process.env.ProgramFiles || `${
1515
const programFilesX86 = process.env['ProgramFiles(x86)'] || `${programFiles} (x86)`
1616

1717
const winDefaultLocationsArray = []
18-
for (const majorMinor of ['39', '38', '37', '36']) {
18+
for (const majorMinor of ['311', '310', '39', '38']) {
1919
if (foundLocalAppData) {
2020
winDefaultLocationsArray.push(
2121
`${localAppData}\\Programs\\Python\\Python${majorMinor}\\python.exe`,
@@ -114,7 +114,20 @@ PythonFinder.prototype = {
114114
},
115115
check: this.checkCommand,
116116
arg: this.env.PYTHON
117-
},
117+
}
118+
]
119+
120+
if (this.win) {
121+
checks.push({
122+
before: () => {
123+
this.addLog(
124+
'checking if the py launcher can be used to find Python 3')
125+
},
126+
check: this.checkPyLauncher
127+
})
128+
}
129+
130+
checks.push(...[
118131
{
119132
before: () => { this.addLog('checking if "python3" can be used') },
120133
check: this.checkCommand,
@@ -125,7 +138,7 @@ PythonFinder.prototype = {
125138
check: this.checkCommand,
126139
arg: 'python'
127140
}
128-
]
141+
]);
129142

130143
if (this.win) {
131144
for (var i = 0; i < this.winDefaultLocations.length; ++i) {
@@ -139,13 +152,6 @@ PythonFinder.prototype = {
139152
arg: location
140153
})
141154
}
142-
checks.push({
143-
before: () => {
144-
this.addLog(
145-
'checking if the py launcher can be used to find Python 3')
146-
},
147-
check: this.checkPyLauncher
148-
})
149155
}
150156

151157
return checks

0 commit comments

Comments
 (0)