Skip to content

Commit

Permalink
Reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 21, 2024
1 parent efd2d94 commit 19e34cd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/uv-cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ workspace = true

[dependencies]
cache-key = { workspace = true }
distribution-filename = { workspace = true }
distribution-types = { workspace = true }
pypi-types = { workspace = true }
uv-fs = { workspace = true }
uv-normalize = { workspace = true }

Expand All @@ -31,3 +31,4 @@ tempfile = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
walkdir = { workspace = true }
rmp-serde = { workspace = true }
23 changes: 9 additions & 14 deletions crates/uv-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ use std::io;
use std::io::Write;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;

use distribution_filename::WheelFilename;
use fs_err as fs;
use rustc_hash::FxHashSet;
use tempfile::{tempdir, TempDir};
use tracing::debug;

use distribution_types::InstalledDist;
use uv_fs::{directories, files};
use pypi_types::Metadata23;
use uv_fs::directories;
use uv_normalize::PackageName;

pub use crate::by_timestamp::CachedByTimestamp;
Expand Down Expand Up @@ -607,14 +606,14 @@ impl CacheBucket {
/// Returns the number of entries removed from the cache.
fn remove(self, cache: &Cache, name: &PackageName) -> Result<Removal, io::Error> {
/// Returns `true` if the [`Path`] represents a built wheel for the given package.
fn is_built_wheel(path: &Path, name: &PackageName) -> bool {
let Some(filename) = path.file_name().and_then(|filename| filename.to_str()) else {
fn is_match(path: &Path, name: &PackageName) -> bool {
let Ok(metadata) = fs_err::read(path.join("metadata.msgpack")) else {
return false;
};
let Some(filename) = WheelFilename::from_str(filename).ok() else {
let Ok(metadata) = rmp_serde::from_slice::<Metadata23>(&metadata) else {
return false;
};
filename.name == *name
metadata.name == *name
}

let mut summary = Removal::default();
Expand Down Expand Up @@ -655,9 +654,7 @@ impl CacheBucket {
// search for a wheel matching the package name.
let root = cache.bucket(self).join(WheelCacheKind::Url);
for url in directories(root) {
if directories(&url)
.any(|version| files(version).any(|file| is_built_wheel(&file, name)))
{
if directories(&url).any(|version| is_match(&version, name)) {
summary += rm_rf(url)?;
}
}
Expand All @@ -667,9 +664,7 @@ impl CacheBucket {
// search for a wheel matching the package name.
let root = cache.bucket(self).join(WheelCacheKind::Path);
for path in directories(root) {
if directories(&path)
.any(|version| files(version).any(|file| is_built_wheel(&file, name)))
{
if directories(&path).any(|version| is_match(&version, name)) {
summary += rm_rf(path)?;
}
}
Expand All @@ -680,7 +675,7 @@ impl CacheBucket {
let root = cache.bucket(self).join(WheelCacheKind::Git);
for repository in directories(root) {
for sha in directories(repository) {
if files(&sha).any(|file| is_built_wheel(&file, name)) {
if is_match(&sha, name) {
summary += rm_rf(sha)?;
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-distribution/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
}

// Store the metadata.
let cache_entry = cache_shard.entry(METADATA);
write_atomic(cache_entry.path(), rmp_serde::to_vec(&metadata)?)
let metadata_entry = cache_shard.entry(METADATA);
write_atomic(metadata_entry.path(), rmp_serde::to_vec(&metadata)?)
.await
.map_err(Error::CacheWrite)?;

Expand Down Expand Up @@ -683,8 +683,8 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> {
}

// Store the metadata.
let cache_entry = cache_shard.entry(METADATA);
write_atomic(cache_entry.path(), rmp_serde::to_vec(&metadata)?)
let metadata_entry = cache_shard.entry(METADATA);
write_atomic(metadata_entry.path(), rmp_serde::to_vec(&metadata)?)
.await
.map_err(Error::CacheWrite)?;

Expand Down
1 change: 0 additions & 1 deletion requirements.in

This file was deleted.

1 change: 0 additions & 1 deletion scripts/requirements/all-kinds.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ werkzeug @ https://files.pythonhosted.org/packages/0d/cc/ff1904eb5eb4b455e442834
# git source dist
pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git

anyio @ /Users/crmarsh/Downloads/anyio-4.3.0.tar.gz

0 comments on commit 19e34cd

Please sign in to comment.