-
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
Rez pip error handling improvements #1734
base: main
Are you sure you want to change the base?
Rez pip error handling improvements #1734
Conversation
…ython package not found in resolve Signed-off-by: Bryce Gattis <[email protected]>
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Previous this had a terrible traceback like this:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "D:\Code\rez\venv\Scripts\rez\rez-pip.exe\__main__.py", line 7, in <module>
File "d:\code\rez\venv\Lib\site-packages\rez\cli\_entry_points.py", line 183, in run_rez_pip
return run("pip")
^^^^^^^^^^
File "d:\code\rez\venv\Lib\site-packages\rez\cli\_main.py", line 189, in run
returncode = run_cmd()
^^^^^^^^^
File "d:\code\rez\venv\Lib\site-packages\rez\cli\_main.py", line 181, in run_cmd
return func(opts, opts.parser, extra_arg_groups)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\code\rez\venv\Lib\site-packages\rez\cli\pip.py", line 52, in command
pip_install_package(
py_exe, context = find_pip(pip_version, python_version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\code\rez\venv\Lib\site-packages\rez\pip.py", line 92, in find_pip
py_exe, found_pip_version, context = find_pip_from_context(
^^^^^^^^^^^^^^^^^^^^^^
File "d:\code\rez\venv\Lib\site-packages\rez\pip.py", line 201, in find_pip_from_context
py_exe = find_python_in_context(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\code\rez\venv\Lib\site-packages\rez\pip.py", line 141, in find_python_in_context
assert python_package
AssertionError
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.
New output is much more useful:
resolve failed, by bryce@home, on Fri Apr 26 07:52:18 2024, using Rez v3.1.1
requested packages:
python-3.6
pip
~platform==windows (implicit)
~arch==AMD64 (implicit)
~os==windows-10.0.19045.SP0 (implicit)
The context failed to resolve:
The following package conflicts occurred: (python-3.7+ <--!--> python==3.6.8)
Resolve paths starting from initial requests to conflict:
python-3.6 --> python-3.6.8
pip --> pip-24.0 --> python-3.7+
To see a graph of the failed resolution, add --fail-graph in your rez-env or rez-build command.
07:52:18 WARNING Found no pip in any python and/or pip rez packages!
07:52:18 WARNING Falling back to pip installed in rez own virtualenv:
07:52:18 WARNING pip: 23.2.1 (d:\code\rez\venv\Lib\site-packages\pip\__init__.py)
07:52:18 WARNING python: 3.11.4 (d:\code\rez\venv\scripts\python.exe)
07:52:18 INFO Installing 'elastic-transport==8.12.0' with pip taken from 'd:\\code\\rez\\venv\\scripts\\python.exe'
07:52:18 ERROR ResolvedContextError: Cannot perform operation in a failed context
context = context.copy() | ||
context.append_sys_path = False # #826 | ||
|
||
python_package = context.get_resolved_package("python") | ||
assert python_package | ||
if not python_package: |
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.
Will this condition ever be true? If we resolved python and the solve was successful, context.get_resolved_package("python")
should always return a python package no?
@@ -134,11 +132,19 @@ 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. | |||
# | |||
success = (context.status == ResolverStatus.solved) | |||
if not success: | |||
context.print_info(buf=sys.stderr) |
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 ... "
Co-authored-by: Jean-Christophe Morin <[email protected]> Signed-off-by: BryceGattis <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1734 +/- ##
==========================================
+ Coverage 58.29% 58.39% +0.10%
==========================================
Files 126 126
Lines 17159 17167 +8
Branches 3505 3508 +3
==========================================
+ Hits 10002 10025 +23
+ Misses 6493 6477 -16
- Partials 664 665 +1 ☔ View full report in Codecov by Sentry. |
Add error handling for failed resolve and improve error handling if python package not found in resolve