mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-10 12:36:27 +00:00
Use cache for Python install temporary directories (#5787)
## Summary It's fine for this to be in the cache, I think, since we don't necessarily need to colocate it with the Python directory. Closes https://github.com/astral-sh/uv/issues/5747.
This commit is contained in:
parent
02eba290f6
commit
bb6ac67df3
4 changed files with 14 additions and 4 deletions
|
@ -14,6 +14,7 @@ use tracing::{debug, instrument};
|
|||
use url::Url;
|
||||
|
||||
use pypi_types::{HashAlgorithm, HashDigest};
|
||||
use uv_cache::Cache;
|
||||
use uv_client::WrappedReqwestError;
|
||||
use uv_extract::hash::Hasher;
|
||||
use uv_fs::{rename_with_retry, Simplified};
|
||||
|
@ -401,11 +402,12 @@ impl ManagedPythonDownload {
|
|||
}
|
||||
|
||||
/// Download and extract
|
||||
#[instrument(skip(client, parent_path, reporter), fields(download = % self.key()))]
|
||||
#[instrument(skip(client, parent_path, cache, reporter), fields(download = % self.key()))]
|
||||
pub async fn fetch(
|
||||
&self,
|
||||
client: &uv_client::BaseClient,
|
||||
parent_path: &Path,
|
||||
cache: &Cache,
|
||||
reporter: Option<&dyn Reporter>,
|
||||
) -> Result<DownloadResult, Error> {
|
||||
let url = Url::parse(self.url)?;
|
||||
|
@ -428,7 +430,7 @@ impl ManagedPythonDownload {
|
|||
.map(|reporter| (reporter, reporter.on_download_start(&self.key, size)));
|
||||
|
||||
// Download and extract into a temporary directory.
|
||||
let temp_dir = tempfile::tempdir_in(parent_path).map_err(Error::DownloadDirError)?;
|
||||
let temp_dir = tempfile::tempdir_in(cache.root()).map_err(Error::DownloadDirError)?;
|
||||
|
||||
debug!(
|
||||
"Downloading {url} to temporary location {}",
|
||||
|
|
|
@ -129,7 +129,9 @@ impl PythonInstallation {
|
|||
let client = client_builder.build();
|
||||
|
||||
info!("Fetching requested Python...");
|
||||
let result = download.fetch(&client, installations_dir, reporter).await?;
|
||||
let result = download
|
||||
.fetch(&client, installations_dir, cache, reporter)
|
||||
.await?;
|
||||
|
||||
let path = match result {
|
||||
DownloadResult::AlreadyAvailable(path) => path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue