Allow pip compile to fall back to find_best for --python#17218
Allow pip compile to fall back to find_best for --python#17218
pip compile to fall back to find_best for --python#17218Conversation
| if let Some(python_missing_download) = python_missing_download { | ||
| warn_user!( | ||
| "The requested Python version {} was not found and could not be downloaded; {} will be used to build dependencies instead.", | ||
| python_missing_download, | ||
| interpreter.python_version(), | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
There's an argument to be made here that this should print the original error too... Let me know.
| Err(uv_python::Error::MissingPython(..)) => (None, Some(python)), | ||
| Err(uv_python::Error::Discovery(err)) if !err.is_critical() => (None, Some(python)), |
There was a problem hiding this comment.
These are taken from find_or_download. Maybe this is an argument for some kind of predicate function for uv_python::Error so this case can be tested in one place?
| .await?; | ||
| let interpreter = if let Some(python) = python.as_ref() { | ||
|
|
||
| let (installation, python_missing_download) = if let Some(python) = python.as_ref() { |
There was a problem hiding this comment.
The reason why python_missing_download is an Option instead of a bool is to avoid needing to check a bool and let Some(python) = python.as_ref() a second time.
The reason why this exists at all is to detect the case when the attempt to download failed in the first place, I couldn't find some way of testing if an interpreter satisfied a specific version. If there is a way to do that, let me know, then this code can simplified.
|
Might be a candidate for the breaking label? I guess the previous PR was too... |
|
|
||
| if let Some(python_missing_download) = python_missing_download { | ||
| warn_user!( | ||
| "The requested Python version {} was not found and could not be downloaded; {} will be used to build dependencies instead.", |
There was a problem hiding this comment.
Maybe this should be is not available and could not be downloaded or it could just be is not available like the other message?
|
I actually don't think this is right. We don't fall back to |
Summary
Partially address #16709.
For cases when
uv pip compileis used with--python <ver>and this flag is being honoured, allow falling back tofind_bestin cases where the python version cannot be found or downloaded.Test Plan
A number of existing testcases already hit this and have been updated.