-
Notifications
You must be signed in to change notification settings - Fork 339
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
Rez pip error handling improvements #1734
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from rez.vendor.distlib.database import DistributionPath | ||
from rez.vendor.packaging.version import Version as PackagingVersion | ||
from rez.vendor.packaging.specifiers import Specifier | ||
from rez.resolved_context import ResolvedContext | ||
from rez.resolved_context import ResolvedContext, ResolverStatus | ||
from rez.utils.execution import Popen | ||
from rez.utils.pip import get_rez_requirements, pip_to_rez_package_name, \ | ||
pip_to_rez_version | ||
|
@@ -124,8 +124,6 @@ def find_python_in_context(context): | |
|
||
Args: | ||
context (ResolvedContext): Resolved context with Python and pip. | ||
name (str): Name of the package for Python instead of "python". | ||
default (str): Force a particular fallback path for Python executable. | ||
|
||
Returns: | ||
str or None: Path to Python executable, if any. | ||
|
@@ -134,11 +132,18 @@ def find_python_in_context(context): | |
# Create a copy of the context with systems paths removed, so we don't | ||
# accidentally find a system python install. | ||
# | ||
if context.status != ResolverStatus.solved: | ||
context.print_info(buf=sys.stderr) | ||
return None | ||
|
||
context = context.copy() | ||
context.append_sys_path = False # #826 | ||
|
||
python_package = context.get_resolved_package("python") | ||
assert python_package | ||
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. Previous this had a terrible traceback like this:
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. New output is much more useful:
|
||
if not python_package: | ||
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. Will this condition ever be true? If we resolved python and the solve was successful, |
||
raise PackageNotFoundError( | ||
f"python package family not found in context: {context}" | ||
) | ||
|
||
# look for (eg) python3.7, then python3, then python | ||
name_template = "python{}" | ||
|
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 we add a custom error message too? Something like "Failed to resolve ... "