mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-17 05:47:45 +00:00
Colocate Python install cache with destination directory (#6043)
## Summary Closes https://github.com/astral-sh/uv/issues/6036.
This commit is contained in:
parent
e27a1fce60
commit
ae7a8d7f33
5 changed files with 27 additions and 19 deletions
|
@ -95,6 +95,11 @@ impl ManagedPythonInstallations {
|
|||
))
|
||||
}
|
||||
|
||||
/// Return the location of the cache directory for managed Python installations.
|
||||
pub fn cache(&self) -> PathBuf {
|
||||
self.root.join(".cache")
|
||||
}
|
||||
|
||||
/// Initialize the Python installation directory.
|
||||
///
|
||||
/// Ensures the directory is created.
|
||||
|
@ -119,6 +124,10 @@ impl ManagedPythonInstallations {
|
|||
// Create the directory, if it doesn't exist.
|
||||
fs::create_dir_all(root)?;
|
||||
|
||||
// Create the cache directory, if it doesn't exist.
|
||||
let cache = self.cache();
|
||||
fs::create_dir_all(&cache)?;
|
||||
|
||||
// Add a .gitignore.
|
||||
match fs::OpenOptions::new()
|
||||
.write(true)
|
||||
|
@ -166,8 +175,10 @@ impl ManagedPythonInstallations {
|
|||
})
|
||||
}
|
||||
};
|
||||
let cache = self.cache();
|
||||
Ok(dirs
|
||||
.into_iter()
|
||||
.filter(|path| *path != cache)
|
||||
.filter_map(|path| {
|
||||
ManagedPythonInstallation::new(path)
|
||||
.inspect_err(|err| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue