Build source distributions in the cache directory instead of the global temporary directory (#1628)

Addresses report in https://github.com/astral-sh/uv/issues/1444 where a
temporary directory is created outside of the cache directory or current
virtual environment.

There is one additional usage of bare `tempdir` outside of tests we may
want to change:


2586f655bb/crates/install-wheel-rs/src/wheel.rs (L567)
This commit is contained in:
Zanie Blue 2024-02-18 15:05:39 -06:00 committed by GitHub
parent ceb953be0f
commit 63c313425f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,7 +19,7 @@ use once_cell::sync::Lazy;
use pyproject_toml::{BuildSystem, Project};
use regex::Regex;
use serde::{Deserialize, Serialize};
use tempfile::{tempdir, tempdir_in, TempDir};
use tempfile::{tempdir_in, TempDir};
use thiserror::Error;
use tokio::process::Command;
use tokio::sync::Mutex;
@ -283,7 +283,7 @@ impl SourceBuild {
setup_py: SetupPyStrategy,
build_kind: BuildKind,
) -> Result<SourceBuild, Error> {
let temp_dir = tempdir()?;
let temp_dir = tempdir_in(build_context.cache().root())?;
let metadata = match fs::metadata(source) {
Ok(metadata) => metadata,