mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
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: https://github.com/nodejs/node-gyp/issues/2130 Refs: https://docs.python.org/3/using/windows.html#launcher PR-URL: https://github.com/nodejs/node-gyp/pull/2131 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
parent
741ab096d5
commit
c255ffbf6a
2 changed files with 4 additions and 10 deletions
|
@ -119,7 +119,7 @@ PythonFinder.prototype = {
|
||||||
checks.push({
|
checks.push({
|
||||||
before: () => {
|
before: () => {
|
||||||
this.addLog(
|
this.addLog(
|
||||||
'checking if the py launcher can be used to find Python 2')
|
'checking if the py launcher can be used to find Python')
|
||||||
},
|
},
|
||||||
check: this.checkPyLauncher
|
check: this.checkPyLauncher
|
||||||
})
|
})
|
||||||
|
@ -188,15 +188,10 @@ PythonFinder.prototype = {
|
||||||
// Distributions of Python on Windows by default install with the "py.exe"
|
// Distributions of Python on Windows by default install with the "py.exe"
|
||||||
// Python launcher which is more likely to exist than the Python executable
|
// Python launcher which is more likely to exist than the Python executable
|
||||||
// being in the $PATH.
|
// being in the $PATH.
|
||||||
// Because the Python launcher supports all versions of Python, we have to
|
|
||||||
// explicitly request a Python 2 version. This is done by supplying "-2" as
|
|
||||||
// the first command line argument. Since "py.exe -2" would be an invalid
|
|
||||||
// executable for "execFile", we have to use the launcher to figure out
|
|
||||||
// where the actual "python.exe" executable is located.
|
|
||||||
checkPyLauncher: function checkPyLauncher (errorCallback) {
|
checkPyLauncher: function checkPyLauncher (errorCallback) {
|
||||||
this.log.verbose(
|
this.log.verbose(
|
||||||
`- executing "${this.pyLauncher}" to get Python 2 executable path`)
|
`- executing "${this.pyLauncher}" to get Python executable path`)
|
||||||
this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false,
|
this.run(this.pyLauncher, this.argsExecutable, false,
|
||||||
function (err, execPath) {
|
function (err, execPath) {
|
||||||
// Possible outcomes: same as checkCommand
|
// Possible outcomes: same as checkCommand
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -146,14 +146,13 @@ test('find python - no python2, no python, unix', function (t) {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('find python - no python, use python launcher', function (t) {
|
test('find python - no python, use python launcher', function (t) {
|
||||||
t.plan(4)
|
t.plan(3)
|
||||||
|
|
||||||
var f = new TestPythonFinder(null, done)
|
var f = new TestPythonFinder(null, done)
|
||||||
f.win = true
|
f.win = true
|
||||||
|
|
||||||
f.execFile = function (program, args, opts, cb) {
|
f.execFile = function (program, args, opts, cb) {
|
||||||
if (program === 'py.exe') {
|
if (program === 'py.exe') {
|
||||||
t.notEqual(args.indexOf('-2'), -1)
|
|
||||||
t.notEqual(args.indexOf('-c'), -1)
|
t.notEqual(args.indexOf('-c'), -1)
|
||||||
return cb(null, 'Z:\\snake.exe')
|
return cb(null, 'Z:\\snake.exe')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue