Skip to content

Commit c255ffb

Browse files
DeeDeeGrvagg
authored andcommitted
lib: drop "-2" flag for "py.exe" launcher
Now that node-gyp supports both Python 2 and Python 3, We don't need to explicitly try to find only Python 2. Fixes: #2130 Refs: https://docs.python.org/3/using/windows.html#launcher PR-URL: #2131 Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent 741ab09 commit c255ffb

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lib/find-python.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ PythonFinder.prototype = {
119119
checks.push({
120120
before: () => {
121121
this.addLog(
122-
'checking if the py launcher can be used to find Python 2')
122+
'checking if the py launcher can be used to find Python')
123123
},
124124
check: this.checkPyLauncher
125125
})
@@ -188,15 +188,10 @@ PythonFinder.prototype = {
188188
// Distributions of Python on Windows by default install with the "py.exe"
189189
// Python launcher which is more likely to exist than the Python executable
190190
// being in the $PATH.
191-
// Because the Python launcher supports all versions of Python, we have to
192-
// explicitly request a Python 2 version. This is done by supplying "-2" as
193-
// the first command line argument. Since "py.exe -2" would be an invalid
194-
// executable for "execFile", we have to use the launcher to figure out
195-
// where the actual "python.exe" executable is located.
196191
checkPyLauncher: function checkPyLauncher (errorCallback) {
197192
this.log.verbose(
198-
`- executing "${this.pyLauncher}" to get Python 2 executable path`)
199-
this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false,
193+
`- executing "${this.pyLauncher}" to get Python executable path`)
194+
this.run(this.pyLauncher, this.argsExecutable, false,
200195
function (err, execPath) {
201196
// Possible outcomes: same as checkCommand
202197
if (err) {

test/test-find-python.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,13 @@ test('find python - no python2, no python, unix', function (t) {
146146
})
147147

148148
test('find python - no python, use python launcher', function (t) {
149-
t.plan(4)
149+
t.plan(3)
150150

151151
var f = new TestPythonFinder(null, done)
152152
f.win = true
153153

154154
f.execFile = function (program, args, opts, cb) {
155155
if (program === 'py.exe') {
156-
t.notEqual(args.indexOf('-2'), -1)
157156
t.notEqual(args.indexOf('-c'), -1)
158157
return cb(null, 'Z:\\snake.exe')
159158
}

0 commit comments

Comments
 (0)