Skip to content

Commit 0bd6e46

Browse files
Avoid writing duplicate index URLs with --emit-index-url (#8226)
closes #8116 --------- Co-authored-by: Charlie Marsh <[email protected]>
1 parent 0c445eb commit 0bd6e46

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

crates/uv/src/commands/pip/compile.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::path::Path;
44
use anyhow::{anyhow, Result};
55
use itertools::Itertools;
66
use owo_colors::OwoColorize;
7+
use rustc_hash::FxHashSet;
78
use tracing::debug;
89

910
use uv_cache::Cache;
@@ -466,9 +467,12 @@ pub(crate) async fn pip_compile(
466467
writeln!(writer, "--index-url {}", index.url().verbatim())?;
467468
wrote_preamble = true;
468469
}
470+
let mut seen = FxHashSet::default();
469471
for extra_index in index_locations.implicit_indexes() {
470-
writeln!(writer, "--extra-index-url {}", extra_index.url().verbatim())?;
471-
wrote_preamble = true;
472+
if seen.insert(extra_index.url()) {
473+
writeln!(writer, "--extra-index-url {}", extra_index.url().verbatim())?;
474+
wrote_preamble = true;
475+
}
472476
}
473477
}
474478

crates/uv/tests/it/pip_compile.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5263,7 +5263,8 @@ fn emit_index_urls() -> Result<()> {
52635263
.arg("--index-url")
52645264
.arg("https://test.pypi.org/simple/")
52655265
.arg("--extra-index-url")
5266-
.arg("https://pypi.org/simple"), @r###"
5266+
.arg("https://pypi.org/simple")
5267+
.env("UV_EXTRA_INDEX_URL", "https://pypi.org/simple"), @r###"
52675268
success: true
52685269
exit_code: 0
52695270
----- stdout -----

0 commit comments

Comments
 (0)