-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add support for global uv python pin
#12115
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ use std::path::{Path, PathBuf}; | |||
| use fs_err as fs; | ||||
| use itertools::Itertools; | ||||
| use tracing::debug; | ||||
| use uv_dirs::user_uv_config_dir; | ||||
| use uv_fs::Simplified; | ||||
|
|
||||
| use crate::PythonRequest; | ||||
|
|
@@ -69,7 +70,13 @@ impl PythonVersionFile { | |||
| options: &DiscoveryOptions<'_>, | ||||
| ) -> Result<Option<Self>, std::io::Error> { | ||||
| let Some(path) = Self::find_nearest(working_directory, options) else { | ||||
| return Ok(None); | ||||
| // Not found in directory or its ancestors. Looking in user-level config. | ||||
| return Ok(match user_uv_config_dir() { | ||||
| Some(user_dir) => Self::discover_user_config(user_dir, options) | ||||
|
Member
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. I wonder if we should co-locate this with the Line 140 in ba74b9e
--system flag separately in the future once we have more feedback.
Contributor
Author
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. That's an interesting question. But I agree we should consider it separately from this PR. |
||||
| .await? | ||||
| .or(None), | ||||
| None => None, | ||||
| }); | ||||
| }; | ||||
|
|
||||
| if options.no_config { | ||||
|
|
@@ -84,6 +91,22 @@ impl PythonVersionFile { | |||
| Self::try_from_path(path).await | ||||
| } | ||||
|
|
||||
| pub async fn discover_user_config( | ||||
zanieb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| user_config_working_directory: impl AsRef<Path>, | ||||
| options: &DiscoveryOptions<'_>, | ||||
| ) -> Result<Option<Self>, std::io::Error> { | ||||
| if !options.no_config { | ||||
| if let Some(path) = | ||||
| Self::find_in_directory(user_config_working_directory.as_ref(), options) | ||||
| .into_iter() | ||||
| .find(|path| path.is_file()) | ||||
| { | ||||
| return Self::try_from_path(path).await; | ||||
| } | ||||
| } | ||||
| Ok(None) | ||||
| } | ||||
|
|
||||
| fn find_nearest(path: impl AsRef<Path>, options: &DiscoveryOptions<'_>) -> Option<PathBuf> { | ||||
| path.as_ref() | ||||
| .ancestors() | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.