-
Notifications
You must be signed in to change notification settings - Fork 338
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
Explicit fail when python executable is not found #1236
Explicit fail when python executable is not found #1236
Conversation
src/rez/pip.py
Outdated
@@ -202,6 +202,9 @@ def find_pip_from_context(python_version, pip_version=None): | |||
|
|||
py_exe = find_python_in_context(context) | |||
|
|||
if not py_exe: | |||
raise RezSystemError("Failed to locate Python executable from context {}".format(context)) |
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.
I think returning early like return None, None, context
would be slightly better. That's because of the way the function is called: https://github.com/nerdvegas/rez/blob/master/src/rez/pip.py#L92-L101.
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.
Oh, took me a while but I think I see what you mean.
This way we keep on with the logic of find_pip
, hoping that we actually find a valid executable later.
I'll change that right away.
src/rez/pip.py
Outdated
@@ -202,6 +202,10 @@ def find_pip_from_context(python_version, pip_version=None): | |||
|
|||
py_exe = find_python_in_context(context) | |||
|
|||
if not py_exe: | |||
print_debug("Failed to locate python executable from context") |
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.
This log might be redundant I think. The _check_found
function already logs when something isn't found and I also have a personal preference to let the caller log instead of letting the callee (find_pip_from_context) log.
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.
Alright, to me the log seemed consistent with code above and also acted as a comment for the return
statement.
But I am fine with removing it.
Fixed in 2a64909
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
Thanks for the fix @aboellinger!
Problem
We have found ourselves in a situation where during a call to
find_pip_from_context
,find_python_in_context(context)
returnsNone
, resulting in the creation and execution of an invalid command (withNone
provided as an executable path). This ends up breaking downstream insubprocess
with an obscure message.Solution
Raise an explicit error if the executable is not located, before we try to run it.