mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
Try python launcher when stock python is python 3.
Consult the python launcher when the python on the path is python 3. If a python 2 exists on the system, it will tell us. Fixes: https://github.com/nodejs/node-gyp/issues/987 PR-URL: https://github.com/nodejs/node-gyp/pull/992 Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
This commit is contained in:
parent
e3778d9907
commit
37ae7be114
2 changed files with 83 additions and 6 deletions
|
@ -195,6 +195,77 @@ test('find python - no python, use python launcher', function (t) {
|
|||
}
|
||||
})
|
||||
|
||||
test('find python - python 3, use python launcher', function (t) {
|
||||
t.plan(10)
|
||||
|
||||
var f = new TestPythonFinder('python', done)
|
||||
f.env = {}
|
||||
f.win = true
|
||||
|
||||
f.which = function(program, cb) {
|
||||
t.strictEqual(program, 'python')
|
||||
cb(null, program)
|
||||
}
|
||||
f.execFile = function(program, args, opts, cb) {
|
||||
f.execFile = function(program, args, opts, cb) {
|
||||
f.execFile = function(program, args, opts, cb) {
|
||||
t.strictEqual(program, 'Z:\\snake.exe')
|
||||
t.ok(/import platform/.test(args[1]))
|
||||
cb(null, '2.7.0')
|
||||
}
|
||||
t.strictEqual(program, 'py.exe')
|
||||
t.notEqual(args.indexOf('-2'), -1)
|
||||
t.notEqual(args.indexOf('-c'), -1)
|
||||
cb(null, 'Z:\\snake.exe')
|
||||
}
|
||||
t.strictEqual(program, 'python')
|
||||
t.ok(/import platform/.test(args[1]))
|
||||
cb(null, '3.0.0')
|
||||
}
|
||||
f.checkPython()
|
||||
|
||||
function done(err, python) {
|
||||
t.strictEqual(err, null)
|
||||
t.strictEqual(python, 'Z:\\snake.exe')
|
||||
}
|
||||
})
|
||||
|
||||
test('find python - python 3, use python launcher, python 2 too old',
|
||||
function (t) {
|
||||
t.plan(9)
|
||||
|
||||
var f = new TestPythonFinder('python', done)
|
||||
f.checkedPythonLauncher = false
|
||||
f.env = {}
|
||||
f.win = true
|
||||
|
||||
f.which = function(program, cb) {
|
||||
t.strictEqual(program, 'python')
|
||||
cb(null, program)
|
||||
}
|
||||
f.execFile = function(program, args, opts, cb) {
|
||||
f.execFile = function(program, args, opts, cb) {
|
||||
f.execFile = function(program, args, opts, cb) {
|
||||
t.strictEqual(program, 'Z:\\snake.exe')
|
||||
t.ok(/import platform/.test(args[1]))
|
||||
cb(null, '2.3.4')
|
||||
}
|
||||
t.strictEqual(program, 'py.exe')
|
||||
t.notEqual(args.indexOf('-2'), -1)
|
||||
t.notEqual(args.indexOf('-c'), -1)
|
||||
cb(null, 'Z:\\snake.exe')
|
||||
}
|
||||
t.strictEqual(program, 'python')
|
||||
t.ok(/import platform/.test(args[1]))
|
||||
cb(null, '3.0.0')
|
||||
}
|
||||
f.checkPython()
|
||||
|
||||
function done(err, python) {
|
||||
t.ok(/is not supported by gyp/.test(err))
|
||||
}
|
||||
})
|
||||
|
||||
test('find python - no python, no python launcher, good guess', function (t) {
|
||||
t.plan(6)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue