Skip to content

Commit

Permalink
merged two PRs 1269 & 1325
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidmar committed Nov 5, 2017
1 parent 5d9a691 commit 9c7ad90
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ PythonFinder.prototype = {
stat: fs.stat,
which: which,
win: win,
badVersion: '',

checkPython: function checkPython () {
this.log.verbose('check python',
Expand Down Expand Up @@ -468,6 +469,9 @@ PythonFinder.prototype = {
var valid = false
try {
valid = range.test(version)
if (!valid){
this.badVersion = version
}
} catch (e) {
this.log.silly('range.test() error', e)
}
Expand All @@ -476,29 +480,27 @@ PythonFinder.prototype = {
} else if (this.win && this.checkPythonLauncherDepth === 0) {
this.checkPythonLauncher()
} else {
this.failPythonVersion(version)
this.failPythonVersion()
}
}.bind(this))
},

failNoPython: function failNoPython () {
const err = new Error(
'\n******************************************************************\n' +
`node-gyp can't use "${this.python}",\n` +
'It is recommended that you install python 2.7, set the PYTHON env,\n' +
'or use the --python switch to point to a Python >= v2.6.0 & < 3.0.0.\n' +
'For more information consult the documentation at:\n' +
'https://github.com/nodejs/node-gyp#installation\n' +
'***********************************************************************'
);
err.noPython = true;
this.callback(err)
if (this.badVersion != '') {
// win scenario, where we found python but invalid version. No other python versions found
this.failPythonVersion()
}

var errmsg =
'Can\'t find Python executable "' + this.python +
'", you can set the PYTHON env variable.'
this.callback(new Error(errmsg))
},

failPythonVersion: function failPythonVersion (badVersion) {
const err = new Error(
'\n******************************************************************\n' +
`Python executable "${this.python}" is v${badVersion}\n` +
`Python executable "${this.python}" is v${this.badVersion}\n` +
'this version is not supported by GYP and hence by node-gyp.\n' +
'It is recommended that you install python 2.7, set the PYTHON env,\n' +
'or use the --python switch to point to a Python >= v2.6.0 & < 3.0.0.\n' +
Expand All @@ -513,6 +515,7 @@ PythonFinder.prototype = {
// Called on Windows when "python" isn't available in the current $PATH.
// We are going to check if "%SystemDrive%\python27\python.exe" exists.
guessPython: function guessPython () {
this.checkPythonLauncherDepth += 1
this.log.verbose('could not find "' + this.python + '". guessing location')
var rootDir = this.env.SystemDrive || 'C:\\'
if (rootDir[rootDir.length - 1] !== '\\') {
Expand Down

0 comments on commit 9c7ad90

Please sign in to comment.