-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python: more informative error #1269
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"asi": true, | ||
"laxcomma": true, | ||
"es5": true, | ||
"esversion": 6, | ||
"node": true, | ||
"strict": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,7 +461,7 @@ PythonFinder.prototype = { | |
this.log.silly('stripping "rc" identifier from version') | ||
version = version.replace(/rc(.*)$/ig, '') | ||
} | ||
var range = semver.Range('>=2.5.0 <3.0.0') | ||
var range = semver.Range('>=2.6.0 <3.0.0') | ||
var valid = false | ||
try { | ||
valid = range.test(version) | ||
|
@@ -479,19 +479,32 @@ PythonFinder.prototype = { | |
}, | ||
|
||
failNoPython: function failNoPython () { | ||
var errmsg = | ||
'Can\'t find Python executable "' + this.python + | ||
'", you can set the PYTHON env variable.' | ||
this.callback(new Error(errmsg)) | ||
const err = new Error( | ||
'\n******************************************************************\n' + | ||
`node-gyp can't use "${this.python}",\n` + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to change the wording from "can't find" to "can't use"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes because this error is printed both when python can't be found, and on windows when it's a bad version.
which makes less sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to distinguish between "can't be found" and bad version? In the example output in the PR description (i.e. the not found case), I think the message is now worse.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's quite convoluted code... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't notice this PR before doing my own fix. Solves the above issue and detects if there is a wrong version + a possible infinite loop fix. See #1325 |
||
'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' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be 2.7.0 instead of 2.6.0 at this point? Python 2.6 has been EOL for 5 years. |
||
'For more information consult the documentation at:\n' + | ||
'https://github.com/nodejs/node-gyp#installation\n' + | ||
'***********************************************************************' | ||
); | ||
err.noPython = true; | ||
this.callback(err) | ||
}, | ||
|
||
failPythonVersion: function failPythonVersion (badVersion) { | ||
var errmsg = | ||
'Python executable "' + this.python + | ||
'" is v' + badVersion + ', which is not supported by gyp.\n' + | ||
'You can pass the --python switch to point to ' + | ||
'Python >= v2.5.0 & < 3.0.0.' | ||
this.callback(new Error(errmsg)) | ||
const err = new Error( | ||
'\n******************************************************************\n' + | ||
`Python executable "${this.python}" is v${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' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be 2.7.0 instead of 2.6.0 at this point? Python 2.6 has been EOL for 5 years. |
||
'For more information consult the documentation at:\n' + | ||
'https://github.com/nodejs/node-gyp#installation\n' + | ||
'***********************************************************************' | ||
); | ||
err.noPython = true; | ||
this.callback(err) | ||
}, | ||
|
||
// Called on Windows when "python" isn't available in the current $PATH. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 2.7.0 instead of 2.6.0 at this point? Python 2.6 has been EOL for 5 years.