Skip to content

Commit 55b57a0

Browse files
committed
Merge branch 'main' into ignore-quiet-flag-for-pip-list-and-tree
2 parents 3b41ab0 + 7e2822d commit 55b57a0

File tree

6 files changed

+227
-33
lines changed

6 files changed

+227
-33
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ jobs:
298298

299299
- name: "Cargo test"
300300
working-directory: ${{ env.UV_WORKSPACE }}
301+
env:
302+
# Avoid permission errors during concurrent tests
303+
# See https://github.com/astral-sh/uv/issues/6940
304+
UV_LINK_MODE: copy
301305
run: |
302306
cargo nextest run --no-default-features --features python,pypi --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 20 --final-status-level slow
303307

crates/uv-resolver/src/lock/mod.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ impl Lock {
108108
let mut packages = BTreeMap::new();
109109
let requires_python = graph.requires_python.clone();
110110

111+
// Determine the set of packages included at multiple versions.
112+
let mut seen = FxHashSet::default();
113+
let mut duplicates = FxHashSet::default();
114+
for node_index in graph.petgraph.node_indices() {
115+
let ResolutionGraphNode::Dist(dist) = &graph.petgraph[node_index] else {
116+
continue;
117+
};
118+
if !dist.is_base() {
119+
continue;
120+
}
121+
if !seen.insert(dist.name()) {
122+
duplicates.insert(dist.name());
123+
}
124+
}
125+
111126
// Lock all base packages.
112127
for node_index in graph.petgraph.node_indices() {
113128
let ResolutionGraphNode::Dist(dist) = &graph.petgraph[node_index] else {
@@ -116,10 +131,20 @@ impl Lock {
116131
if !dist.is_base() {
117132
continue;
118133
}
119-
let fork_markers = graph
120-
.fork_markers(dist.name(), &dist.version, dist.dist.version_or_url().url())
121-
.cloned()
122-
.unwrap_or_default();
134+
135+
// If there are multiple distributions for the same package, include the markers of all
136+
// forks that included the current distribution.
137+
let fork_markers = if duplicates.contains(dist.name()) {
138+
graph
139+
.fork_markers
140+
.iter()
141+
.filter(|fork_markers| !fork_markers.is_disjoint(&dist.marker))
142+
.cloned()
143+
.collect()
144+
} else {
145+
vec![]
146+
};
147+
123148
let mut package = Package::from_annotated_dist(dist, fork_markers, root)?;
124149
Self::remove_unreachable_wheels(graph, &requires_python, node_index, &mut package);
125150

crates/uv-resolver/src/resolution/graph.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use uv_distribution_types::{
1616
use uv_git::GitResolver;
1717
use uv_normalize::{ExtraName, GroupName, PackageName};
1818
use uv_pep440::{Version, VersionSpecifier};
19-
use uv_pep508::{MarkerEnvironment, MarkerTree, MarkerTreeKind, VerbatimUrl};
19+
use uv_pep508::{MarkerEnvironment, MarkerTree, MarkerTreeKind};
2020
use uv_pypi_types::{HashDigest, ParsedUrlError, Requirement, VerbatimParsedUrl, Yanked};
2121

2222
use crate::graph_ops::marker_reachability;
@@ -31,7 +31,7 @@ use crate::{
3131
ResolverMarkers, VersionsResponse,
3232
};
3333

34-
pub(crate) type MarkersForDistribution = FxHashMap<(Version, Option<VerbatimUrl>), Vec<MarkerTree>>;
34+
pub(crate) type MarkersForDistribution = Vec<MarkerTree>;
3535

3636
/// A complete resolution graph in which every node represents a pinned package and every edge
3737
/// represents a dependency between two pinned packages.
@@ -54,9 +54,6 @@ pub struct ResolutionGraph {
5454
pub(crate) overrides: Overrides,
5555
/// The options that were used to build the graph.
5656
pub(crate) options: Options,
57-
/// If there are multiple options for a package, track which fork they belong to so we
58-
/// can write that to the lockfile and later get the correct preference per fork back.
59-
pub(crate) package_markers: FxHashMap<PackageName, MarkersForDistribution>,
6057
}
6158

6259
#[derive(Debug, Clone)]
@@ -131,8 +128,6 @@ impl ResolutionGraph {
131128
package_markers
132129
.entry(package.name.clone())
133130
.or_default()
134-
.entry((version.clone(), package.url.clone().map(|url| url.verbatim)))
135-
.or_default()
136131
.push(markers.clone());
137132
}
138133
}
@@ -239,7 +234,6 @@ impl ResolutionGraph {
239234
let graph = Self {
240235
petgraph,
241236
requires_python,
242-
package_markers,
243237
diagnostics,
244238
requirements: requirements.to_vec(),
245239
constraints: constraints.clone(),
@@ -727,22 +721,6 @@ impl ResolutionGraph {
727721
Ok(conjunction)
728722
}
729723

730-
/// If there are multiple distributions for the same package name, return the markers of the
731-
/// fork(s) that contained this distribution, otherwise return `None`.
732-
pub fn fork_markers(
733-
&self,
734-
package_name: &PackageName,
735-
version: &Version,
736-
url: Option<&VerbatimUrl>,
737-
) -> Option<&Vec<MarkerTree>> {
738-
let package_markers = &self.package_markers.get(package_name)?;
739-
if package_markers.len() == 1 {
740-
None
741-
} else {
742-
Some(&package_markers[&(version.clone(), url.cloned())])
743-
}
744-
}
745-
746724
/// Returns a sequence of conflicting distribution errors from this
747725
/// resolution.
748726
///

crates/uv/tests/it/common/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ impl TestContext {
299299

300300
let mut filters = Vec::new();
301301

302+
// Exclude `link-mode` on Windows since we set it in the remote test suite
303+
if cfg!(windows) {
304+
filters.push(("--link-mode <LINK_MODE> ".to_string(), String::new()));
305+
filters.push(((r#"link-mode = "copy"\n"#).to_string(), String::new()));
306+
}
307+
302308
filters.extend(
303309
Self::path_patterns(&cache_dir)
304310
.into_iter()
@@ -1112,6 +1118,7 @@ pub fn run_and_format<T: AsRef<str>>(
11121118
/// Execute the command and format its output status, stdout and stderr into a snapshot string.
11131119
///
11141120
/// This function is derived from `insta_cmd`s `spawn_with_info`.
1121+
#[allow(clippy::print_stderr)]
11151122
pub fn run_and_format_with_status<T: AsRef<str>>(
11161123
mut command: impl BorrowMut<Command>,
11171124
filters: impl AsRef<[(T, T)]>,
@@ -1141,13 +1148,21 @@ pub fn run_and_format_with_status<T: AsRef<str>>(
11411148
.output()
11421149
.unwrap_or_else(|err| panic!("Failed to spawn {program}: {err}"));
11431150

1151+
eprintln!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Unfiltered output ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
1152+
eprintln!(
1153+
"----- stdout -----\n{}\n----- stderr -----\n{}",
1154+
String::from_utf8_lossy(&output.stdout),
1155+
String::from_utf8_lossy(&output.stderr),
1156+
);
1157+
eprintln!("────────────────────────────────────────────────────────────────────────────────\n");
1158+
11441159
let mut snapshot = apply_filters(
11451160
format!(
11461161
"success: {:?}\nexit_code: {}\n----- stdout -----\n{}\n----- stderr -----\n{}",
11471162
output.status.success(),
11481163
output.status.code().unwrap_or(!0),
11491164
String::from_utf8_lossy(&output.stdout),
1150-
String::from_utf8_lossy(&output.stderr)
1165+
String::from_utf8_lossy(&output.stderr),
11511166
),
11521167
filters,
11531168
);

crates/uv/tests/it/edit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3383,7 +3383,7 @@ fn add_reject_multiple_git_ref_flags() {
33833383
let context = TestContext::new("3.12");
33843384

33853385
// --tag and --branch
3386-
uv_snapshot!(context
3386+
uv_snapshot!(context.filters(), context
33873387
.add()
33883388
.arg("foo")
33893389
.arg("--tag")
@@ -3404,7 +3404,7 @@ fn add_reject_multiple_git_ref_flags() {
34043404
);
34053405

34063406
// --tag and --rev
3407-
uv_snapshot!(context
3407+
uv_snapshot!(context.filters(), context
34083408
.add()
34093409
.arg("foo")
34103410
.arg("--tag")
@@ -3425,7 +3425,7 @@ fn add_reject_multiple_git_ref_flags() {
34253425
);
34263426

34273427
// --tag and --tag
3428-
uv_snapshot!(context
3428+
uv_snapshot!(context.filters(), context
34293429
.add()
34303430
.arg("foo")
34313431
.arg("--tag")

0 commit comments

Comments
 (0)