Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function configure (gyp, argv, callback) {

// Make sure that Python is in the $PATH
function checkPython () {
var spawn = require('child_process').spawn;

gyp.verbose('checking for Python executable "' + python + '" in the PATH')
which(python, function (err, execPath) {
if (err) {
Expand All @@ -38,7 +40,14 @@ function configure (gyp, argv, callback) {
}
gyp.verbose('`which` succeeded for `' + python + '`', execPath)
// TODO: ensure compatible Python version
getNodeDir()
var pythonVersionCheck = spawn(python, ['-c', 'import sys; print(sys.version_info[0])'])
pythonVersionCheck.stdout.on('data', function(data) {
if (data == 3) {
failPython3(execPath)
} else {
getNodeDir()
}
});
})
}

Expand Down Expand Up @@ -71,6 +80,12 @@ function configure (gyp, argv, callback) {
+ '", you can set the PYTHON env variable.'))
}

function failPython3 (execPath) {
callback(new Error('Python executable "' + execPath
+ '" is Python 3, which is not supported.\n'
+ 'You can set the PYTHON env variable to point to a Python 2 interpreter.'))
}

function getNodeDir () {

// 'python' should be set by now
Expand Down