Skip to content
Merged
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
82 changes: 41 additions & 41 deletions crates/uv-python/src/sysconfig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,87 +68,85 @@ impl ReplacementEntry {
}

/// Mapping for sysconfig keys to lookup and replace with the appropriate entry.
static DEFAULT_VARIABLE_UPDATES: LazyLock<BTreeMap<String, ReplacementEntry>> =
static DEFAULT_VARIABLE_UPDATES: LazyLock<BTreeMap<String, Vec<ReplacementEntry>>> =
LazyLock::new(|| {
BTreeMap::from_iter([
(
"CC".to_string(),
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang".to_string(),
vec![
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang".to_string(),
},
to: "cc".to_string(),
},
to: "cc".to_string(),
},
),
(
"CC".to_string(),
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "/usr/bin/aarch64-linux-gnu-gcc".to_string(),
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "/usr/bin/aarch64-linux-gnu-gcc".to_string(),
},
to: "cc".to_string(),
},
to: "cc".to_string(),
},
],
),
(
"CXX".to_string(),
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang++".to_string(),
vec![
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang++".to_string(),
},
to: "c++".to_string(),
},
to: "c++".to_string(),
},
),
(
"CXX".to_string(),
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "/usr/bin/x86_64-linux-gnu-g++".to_string(),
ReplacementEntry {
mode: ReplacementMode::Partial {
from: "/usr/bin/x86_64-linux-gnu-g++".to_string(),
},
to: "c++".to_string(),
},
to: "c++".to_string(),
},
],
),
(
"BLDSHARED".to_string(),
ReplacementEntry {
vec![ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang".to_string(),
},
to: "cc".to_string(),
},
}],
),
(
"LDSHARED".to_string(),
ReplacementEntry {
vec![ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang".to_string(),
},
to: "cc".to_string(),
},
}],
),
(
"LDCXXSHARED".to_string(),
ReplacementEntry {
vec![ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang++".to_string(),
},
to: "c++".to_string(),
},
}],
),
(
"LINKCC".to_string(),
ReplacementEntry {
vec![ReplacementEntry {
mode: ReplacementMode::Partial {
from: "clang".to_string(),
},
to: "cc".to_string(),
},
}],
),
(
"AR".to_string(),
ReplacementEntry {
vec![ReplacementEntry {
mode: ReplacementMode::Full,
to: "ar".to_string(),
},
}],
),
])
});
Expand Down Expand Up @@ -296,8 +294,10 @@ fn patch_sysconfigdata(mut data: SysconfigData, real_prefix: &Path) -> Sysconfig
let patched = update_prefix(value, real_prefix);
let mut patched = remove_isysroot(&patched);

if let Some(replacement_entry) = DEFAULT_VARIABLE_UPDATES.get(key) {
patched = replacement_entry.patch(&patched);
if let Some(replacement_entries) = DEFAULT_VARIABLE_UPDATES.get(key) {
for replacement_entry in replacement_entries {
patched = replacement_entry.patch(&patched);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we break on first match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, it seems like there could be use for repeated patches? I wouldn't assume break-first behavior when declaring the patches.

}
}

if *value != patched {
Expand Down Expand Up @@ -456,8 +456,8 @@ mod tests {
# system configuration generated and used by the sysconfig module
build_time_vars = {
"AR": "ar",
"CC": "clang -pthread",
"CXX": "clang++ -pthread",
"CC": "cc -pthread",
"CXX": "c++ -pthread",
"PYTHON_BUILD_STANDALONE": 1
}
"##);
Expand Down
Loading