mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-18 18:55:03 +00:00
Fix priority for .python-versions
files in uv python install
(#6382)
In https://github.com/astral-sh/uv/pull/6359, I accidentally made `uv python install` prefer `.python-version` files over `.python-versions` files -.-, kind of niche but it's a regression.
This commit is contained in:
parent
7140cdec79
commit
7d90c29552
8 changed files with 23 additions and 16 deletions
|
@ -25,7 +25,9 @@ impl PythonVersionFile {
|
|||
/// Find a Python version file in the given directory.
|
||||
pub async fn discover(
|
||||
working_directory: impl AsRef<Path>,
|
||||
// TODO(zanieb): Create a `DiscoverySettings` struct for these options
|
||||
no_config: bool,
|
||||
prefer_versions: bool,
|
||||
) -> Result<Option<Self>, std::io::Error> {
|
||||
let versions_path = working_directory.as_ref().join(PYTHON_VERSIONS_FILENAME);
|
||||
let version_path = working_directory.as_ref().join(PYTHON_VERSION_FILENAME);
|
||||
|
@ -39,12 +41,16 @@ impl PythonVersionFile {
|
|||
return Ok(None);
|
||||
}
|
||||
|
||||
if let Some(result) = Self::try_from_path(version_path).await? {
|
||||
return Ok(Some(result));
|
||||
};
|
||||
if let Some(result) = Self::try_from_path(versions_path).await? {
|
||||
return Ok(Some(result));
|
||||
let paths = if prefer_versions {
|
||||
[versions_path, version_path]
|
||||
} else {
|
||||
[version_path, versions_path]
|
||||
};
|
||||
for path in paths {
|
||||
if let Some(result) = Self::try_from_path(path).await? {
|
||||
return Ok(Some(result));
|
||||
};
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue