mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Remove existing built wheels when building source distributions (#559)
This PR modifies the source distribution building to replace any existing targets after building the new wheel. In some cases, the existence of an existing target may be indicative of a bug, so we warn. It's partially a workaround for some (but not all) of the errors in https://github.com/astral-sh/puffin/issues/554.
This commit is contained in:
parent
f99e3560e8
commit
6f055ecf3b
14 changed files with 178 additions and 61 deletions
|
@ -19,6 +19,7 @@ install-wheel-rs = { path = "../install-wheel-rs" }
|
|||
platform-tags = { path = "../platform-tags" }
|
||||
puffin-cache = { path = "../puffin-cache" }
|
||||
puffin-client = { path = "../puffin-client" }
|
||||
puffin-fs = { path = "../puffin-fs" }
|
||||
puffin-git = { path = "../puffin-git" }
|
||||
puffin-normalize = { path = "../puffin-normalize" }
|
||||
puffin-traits = { path = "../puffin-traits" }
|
||||
|
|
|
@ -192,6 +192,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
debug!("Fetching disk-based wheel from registry: {dist} ({size})");
|
||||
|
||||
// Download the wheel into the cache.
|
||||
// TODO(charlie): Use an atomic write, and remove any existing files or directories.
|
||||
fs::create_dir_all(&cache_entry.dir).await?;
|
||||
let mut writer = fs::File::create(cache_entry.path()).await?;
|
||||
tokio::io::copy(&mut reader.compat(), &mut writer).await?;
|
||||
|
@ -224,7 +225,8 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
// Fetch the wheel.
|
||||
let reader = self.client.stream_external(&wheel.url).await?;
|
||||
|
||||
// Download the wheel to the directory.
|
||||
// Download the wheel into the cache.
|
||||
// TODO(charlie): Use an atomic write, and remove any existing files or directories.
|
||||
fs::create_dir_all(&cache_entry.dir).await?;
|
||||
let mut writer = fs::File::create(&cache_entry.path()).await?;
|
||||
tokio::io::copy(&mut reader.compat(), &mut writer).await?;
|
||||
|
|
|
@ -24,8 +24,9 @@ use distribution_types::direct_url::{DirectArchiveUrl, DirectGitUrl};
|
|||
use distribution_types::{GitSourceDist, Identifier, RemoteSource, SourceDist};
|
||||
use install_wheel_rs::read_dist_info;
|
||||
use platform_tags::Tags;
|
||||
use puffin_cache::{digest, write_atomic, CacheBucket, CacheEntry, CanonicalUrl, WheelCache};
|
||||
use puffin_client::{CachedClient, CachedClientError, DataWithCachePolicy, Error};
|
||||
use puffin_cache::{digest, CacheBucket, CacheEntry, CanonicalUrl, WheelCache};
|
||||
use puffin_client::{CachedClient, CachedClientError, DataWithCachePolicy};
|
||||
use puffin_fs::write_atomic;
|
||||
use puffin_git::{Fetch, GitSource};
|
||||
use puffin_normalize::PackageName;
|
||||
use puffin_traits::BuildContext;
|
||||
|
@ -473,15 +474,15 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
|
|||
let cache_dir = self.build_context.cache().bucket(CacheBucket::BuiltWheels);
|
||||
fs::create_dir_all(&cache_dir)
|
||||
.await
|
||||
.map_err(Error::CacheWrite)?;
|
||||
let temp_dir = tempfile::tempdir_in(cache_dir).map_err(Error::CacheWrite)?;
|
||||
.map_err(puffin_client::Error::CacheWrite)?;
|
||||
let temp_dir = tempfile::tempdir_in(cache_dir).map_err(puffin_client::Error::CacheWrite)?;
|
||||
let sdist_file = temp_dir.path().join(source_dist_filename);
|
||||
let mut writer = tokio::fs::File::create(&sdist_file)
|
||||
.await
|
||||
.map_err(Error::CacheWrite)?;
|
||||
.map_err(puffin_client::Error::CacheWrite)?;
|
||||
tokio::io::copy(&mut reader, &mut writer)
|
||||
.await
|
||||
.map_err(Error::CacheWrite)?;
|
||||
.map_err(puffin_client::Error::CacheWrite)?;
|
||||
Ok((Some(temp_dir), sdist_file))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue