Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ uv-tool = { path = "crates/uv-tool" }
uv-torch = { path = "crates/uv-torch" }
uv-trampoline-builder = { path = "crates/uv-trampoline-builder" }
uv-types = { path = "crates/uv-types" }
uv-variant-frontend = { path = "crates/uv-variant-frontend" }
uv-variants = { path = "crates/uv-variants" }
uv-version = { path = "crates/uv-version" }
uv-virtualenv = { path = "crates/uv-virtualenv" }
uv-warnings = { path = "crates/uv-warnings" }
Expand Down Expand Up @@ -169,7 +171,7 @@ security-framework = { version = "3" }
self-replace = { version = "1.5.0" }
serde = { version = "1.0.210", features = ["derive", "rc"] }
serde-untagged = { version = "0.1.6" }
serde_json = { version = "1.0.128" }
serde_json = { version = "1.0.128", features = ["preserve_order"] }
sha2 = { version = "0.10.8" }
smallvec = { version = "1.13.2" }
spdx = { version = "0.10.6" }
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-build-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod tests {
// Check that the source dist is reproducible across platforms.
assert_snapshot!(
format!("{:x}", sha2::Sha256::digest(fs_err::read(&source_dist_path).unwrap())),
@"871d1f859140721b67cbeaca074e7a2740c88c38028d0509eba87d1285f1da9e"
@"590388c63ef4379eef57bedafffc6522dd2e3b84e689fe55ba3b1e7f2de8cc13"
);
// Check both the files we report and the actual files
assert_snapshot!(format_file_list(build.source_dist_list_files, src.path()), @r"
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-cache-info/src/cache_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

use serde::Deserialize;
use tracing::{debug, warn};
use tracing::{debug, trace, warn};

use crate::git_info::{Commit, Tags};
use crate::glob::cluster_globs;
Expand Down Expand Up @@ -263,7 +263,7 @@ impl CacheInfo {
}
}

debug!(
trace!(
"Computed cache info: {timestamp:?}, {commit:?}, {tags:?}, {env:?}, {directories:?}"
);

Expand Down
1 change: 1 addition & 0 deletions crates/uv-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ uv-small-str = { workspace = true }
uv-redacted = { workspace = true }
uv-static = { workspace = true }
uv-torch = { workspace = true }
uv-variants = { workspace = true }
uv-version = { workspace = true }
uv-warnings = { workspace = true }

Expand Down
3 changes: 3 additions & 0 deletions crates/uv-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ pub enum ErrorKind {

#[error("Invalid cache control header: `{0}`")]
InvalidCacheControl(String),

#[error("Invalid variants.json format: {0}")]
VariantsJsonFormat(DisplaySafeUrl, #[source] serde_json::Error),
}

impl ErrorKind {
Expand Down
14 changes: 8 additions & 6 deletions crates/uv-client/src/flat_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use url::Url;

use uv_cache::{Cache, CacheBucket};
use uv_cache_key::cache_digest;
use uv_distribution_filename::DistFilename;
use uv_distribution_types::{File, FileLocation, IndexUrl, UrlString};
use uv_distribution_types::{File, FileLocation, IndexEntryFilename, IndexUrl, UrlString};
use uv_pypi_types::HashDigests;
use uv_redacted::DisplaySafeUrl;
use uv_small_str::SmallString;
Expand Down Expand Up @@ -40,7 +39,7 @@ pub enum FindLinksDirectoryError {
/// An entry in a `--find-links` index.
#[derive(Debug, Clone)]
pub struct FlatIndexEntry {
pub filename: DistFilename,
pub filename: IndexEntryFilename,
pub file: File,
pub index: IndexUrl,
}
Expand Down Expand Up @@ -238,7 +237,9 @@ impl<'a> FlatIndexClient<'a> {
})
.filter_map(|file| {
Some(FlatIndexEntry {
filename: DistFilename::try_from_normalized_filename(&file.filename)?,
filename: IndexEntryFilename::try_from_normalized_filename(
&file.filename,
)?,
file,
index: flat_index.clone(),
})
Expand Down Expand Up @@ -308,9 +309,10 @@ impl<'a> FlatIndexClient<'a> {
zstd: None,
};

let Some(filename) = DistFilename::try_from_normalized_filename(filename) else {
// Try to parse as a distribution filename first
let Some(filename) = IndexEntryFilename::try_from_normalized_filename(filename) else {
debug!(
"Ignoring `--find-links` entry (expected a wheel or source distribution filename): {}",
"Ignoring `--find-links` entry (expected a wheel, source distribution, or variants.json filename): {}",
entry.path().display()
);
continue;
Expand Down
59 changes: 59 additions & 0 deletions crates/uv-client/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,4 +1374,63 @@ mod tests {
}
"#);
}

#[test]
fn parse_variants_json() {
// A variants.json without wheels doesn't make much sense, but it's sufficient to test
// parsing.
let text = r#"
<!DOCTYPE html>
<html>
<body>
<h1>Links for jinja2</h1>
<a href="/whl/jinja2-3.1.2-variants.json#sha256=6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61">jinja2-3.1.2-variants.json</a><br/>
</body>
</html>
<!--TIMESTAMP 1703347410-->
"#;
let base = Url::parse("https://download.pytorch.org/whl/jinja2/").unwrap();
let result = SimpleHtml::parse(text, &base).unwrap();
insta::assert_debug_snapshot!(result, @r#"
SimpleHtml {
base: BaseUrl(
DisplaySafeUrl {
scheme: "https",
cannot_be_a_base: false,
username: "",
password: None,
host: Some(
Domain(
"download.pytorch.org",
),
),
port: None,
path: "/whl/jinja2/",
query: None,
fragment: None,
},
),
files: [
PypiFile {
core_metadata: None,
filename: "jinja2-3.1.2-variants.json",
hashes: Hashes {
md5: None,
sha256: Some(
"6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61",
),
sha384: None,
sha512: None,
blake2b: None,
},
requires_python: None,
size: None,
upload_time: None,
url: "/whl/jinja2-3.1.2-variants.json",
yanked: None,
},
],
}
"#);
}
}
Loading
Loading