Colocate Python install cache with destination directory (#6043)
## Summary Closes https://github.com/astral-sh/uv/issues/6036.
This commit is contained in:
@@ -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| {
|
||||
|
||||
Reference in New Issue
Block a user