Rename Python install scratch directory from .cache -> .temp (#9756)

Addressing the confusion in https://github.com/astral-sh/uv/issues/9749
This commit is contained in:
Zanie Blue 2024-12-10 08:41:16 -06:00 committed by GitHub
parent eb21e4bd25
commit cb038582b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 17 deletions

View file

@ -464,12 +464,12 @@ impl ManagedPythonDownload {
} }
/// Download and extract a Python distribution, retrying on failure. /// Download and extract a Python distribution, retrying on failure.
#[instrument(skip(client, installation_dir, cache_dir, reporter), fields(download = % self.key()))] #[instrument(skip(client, installation_dir, scratch_dir, reporter), fields(download = % self.key()))]
pub async fn fetch_with_retry( pub async fn fetch_with_retry(
&self, &self,
client: &uv_client::BaseClient, client: &uv_client::BaseClient,
installation_dir: &Path, installation_dir: &Path,
cache_dir: &Path, scratch_dir: &Path,
reinstall: bool, reinstall: bool,
python_install_mirror: Option<&str>, python_install_mirror: Option<&str>,
pypy_install_mirror: Option<&str>, pypy_install_mirror: Option<&str>,
@ -483,7 +483,7 @@ impl ManagedPythonDownload {
.fetch( .fetch(
client, client,
installation_dir, installation_dir,
cache_dir, scratch_dir,
reinstall, reinstall,
python_install_mirror, python_install_mirror,
pypy_install_mirror, pypy_install_mirror,
@ -514,12 +514,12 @@ impl ManagedPythonDownload {
} }
/// Download and extract a Python distribution. /// Download and extract a Python distribution.
#[instrument(skip(client, installation_dir, cache_dir, reporter), fields(download = % self.key()))] #[instrument(skip(client, installation_dir, scratch_dir, reporter), fields(download = % self.key()))]
pub async fn fetch( pub async fn fetch(
&self, &self,
client: &uv_client::BaseClient, client: &uv_client::BaseClient,
installation_dir: &Path, installation_dir: &Path,
cache_dir: &Path, scratch_dir: &Path,
reinstall: bool, reinstall: bool,
python_install_mirror: Option<&str>, python_install_mirror: Option<&str>,
pypy_install_mirror: Option<&str>, pypy_install_mirror: Option<&str>,
@ -543,7 +543,7 @@ impl ManagedPythonDownload {
.map(|reporter| (reporter, reporter.on_download_start(&self.key, size))); .map(|reporter| (reporter, reporter.on_download_start(&self.key, size)));
// Download and extract into a temporary directory. // Download and extract into a temporary directory.
let temp_dir = tempfile::tempdir_in(cache_dir).map_err(Error::DownloadDirError)?; let temp_dir = tempfile::tempdir_in(scratch_dir).map_err(Error::DownloadDirError)?;
debug!( debug!(
"Downloading {url} to temporary location: {}", "Downloading {url} to temporary location: {}",

View file

@ -137,7 +137,7 @@ impl PythonInstallation {
) -> Result<Self, Error> { ) -> Result<Self, Error> {
let installations = ManagedPythonInstallations::from_settings()?.init()?; let installations = ManagedPythonInstallations::from_settings()?.init()?;
let installations_dir = installations.root(); let installations_dir = installations.root();
let cache_dir = installations.cache(); let scratch_dir = installations.scratch();
let _lock = installations.lock().await?; let _lock = installations.lock().await?;
let download = ManagedPythonDownload::from_request(&request)?; let download = ManagedPythonDownload::from_request(&request)?;
@ -148,7 +148,7 @@ impl PythonInstallation {
.fetch_with_retry( .fetch_with_retry(
&client, &client,
installations_dir, installations_dir,
&cache_dir, &scratch_dir,
false, false,
python_install_mirror, python_install_mirror,
pypy_install_mirror, pypy_install_mirror,

View file

@ -127,9 +127,9 @@ impl ManagedPythonInstallations {
)) ))
} }
/// Return the location of the cache directory for managed Python installations. /// Return the location of the scratch directory for managed Python installations.
pub fn cache(&self) -> PathBuf { pub fn scratch(&self) -> PathBuf {
self.root.join(".cache") self.root.join(".temp")
} }
/// Initialize the Python installation directory. /// Initialize the Python installation directory.
@ -156,9 +156,9 @@ impl ManagedPythonInstallations {
// Create the directory, if it doesn't exist. // Create the directory, if it doesn't exist.
fs::create_dir_all(root)?; fs::create_dir_all(root)?;
// Create the cache directory, if it doesn't exist. // Create the scratch directory, if it doesn't exist.
let cache = self.cache(); let scratch = self.scratch();
fs::create_dir_all(&cache)?; fs::create_dir_all(&scratch)?;
// Add a .gitignore. // Add a .gitignore.
match fs::OpenOptions::new() match fs::OpenOptions::new()
@ -207,7 +207,7 @@ impl ManagedPythonInstallations {
}) })
} }
}; };
let cache = self.cache(); let cache = self.scratch();
Ok(dirs Ok(dirs
.into_iter() .into_iter()
.filter(|path| *path != cache) .filter(|path| *path != cache)

View file

@ -180,7 +180,7 @@ pub(crate) async fn install(
// Read the existing installations, lock the directory for the duration // Read the existing installations, lock the directory for the duration
let installations = ManagedPythonInstallations::from_settings()?.init()?; let installations = ManagedPythonInstallations::from_settings()?.init()?;
let installations_dir = installations.root(); let installations_dir = installations.root();
let cache_dir = installations.cache(); let scratch_dir = installations.scratch();
let _lock = installations.lock().await?; let _lock = installations.lock().await?;
let existing_installations: Vec<_> = installations let existing_installations: Vec<_> = installations
.find_all()? .find_all()?
@ -259,7 +259,7 @@ pub(crate) async fn install(
.fetch_with_retry( .fetch_with_retry(
&client, &client,
installations_dir, installations_dir,
&cache_dir, &scratch_dir,
reinstall, reinstall,
python_install_mirror.as_deref(), python_install_mirror.as_deref(),
pypy_install_mirror.as_deref(), pypy_install_mirror.as_deref(),