Skip to content

Commit cdabfce

Browse files
authored
Revert "Reject symlinked wheel installation destinations" (#21699)
Reverts #21569 to restore the previous wheel installation behavior. This fixes two regressions introduced in uv 0.12.14: - `uv pip install --target=.` fails because the relative installation root normalizes to an empty path. Fixes #21694. - Installing wheels with man pages fails in official Python Docker images, where `/usr/local/man` is a symlink to `share/man`. Fixes #21692. <!-- codex-thread: 01a0a496-3b61-7140-8190-53aa070449d2 -->
1 parent c32f34a commit cdabfce

4 files changed

Lines changed: 70 additions & 429 deletions

File tree

‎crates/uv-install-wheel/src/install.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ pub fn install_wheel<Cache: serde::Serialize, Build: serde::Serialize>(
8888
// > 1.b Check that installer is compatible with Wheel-Version. Warn if minor version is greater, abort if major version is greater.
8989
// > 1.c If Root-Is-Purelib == ‘true’, unpack archive into purelib (site-packages).
9090
// > 1.d Else unpack archive into platlib (site-packages).
91-
let validated_wheel =
92-
ValidatedWheel::new(layout, wheel, &dist_info_prefix, &name, site_packages)?;
91+
let validated_wheel = ValidatedWheel::new(layout, wheel, &dist_info_prefix)?;
9392
trace!(?name, "Extracting wheel files");
94-
link_wheel_files(link_mode, &validated_wheel, state, filename)?;
93+
link_wheel_files(link_mode, site_packages, &validated_wheel, state, filename)?;
9594
trace!(?name, "Extracted wheel files");
9695

9796
// Read the RECORD file.
@@ -127,12 +126,13 @@ pub fn install_wheel<Cache: serde::Serialize, Build: serde::Serialize>(
127126

128127
// 2.a Unpacked archive includes distribution-1.0.dist-info/ and (if there is data) distribution-1.0.data/.
129128
// 2.b Move each subtree of distribution-1.0.data/ onto its destination path. Each subdirectory of distribution-1.0.data/ is a key into a dict of destination directories, such as distribution-1.0.data/(purelib|platlib|headers|scripts|data). The initially supported paths are taken from distutils.command.install.
130-
let data_dir = validated_wheel.installed_data_dir();
129+
let data_dir = site_packages.join(format!("{dist_info_prefix}.data"));
131130
if data_dir.is_dir() {
132131
install_data(
133132
layout,
134133
relocatable,
135-
&validated_wheel,
134+
site_packages,
135+
&data_dir,
136136
&name,
137137
&console_scripts,
138138
&gui_scripts,

‎crates/uv-install-wheel/src/linker.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,22 @@ impl InstallState {
252252
#[instrument(skip_all)]
253253
pub(crate) fn link_wheel_files(
254254
link_mode: LinkMode,
255+
site_packages: impl AsRef<Path>,
255256
wheel: &ValidatedWheel<'_>,
256257
state: &InstallState,
257258
filename: &WheelFilename,
258259
) -> Result<(), Error> {
259-
let site_packages = wheel.destination().as_path();
260-
let wheel_path = wheel.as_path();
261-
register_installed_paths(wheel_path, state, filename)?;
260+
let wheel = wheel.as_path();
261+
let site_packages = site_packages.as_ref();
262+
register_installed_paths(wheel, state, filename)?;
262263

263264
// The `RECORD` file is modified during installation, so it needs a real
264265
// copy rather than a link back to the cache.
265266
let options = LinkOptions::new(link_mode)
266267
.with_mutable_copy_filter(|p: &Path| p.ends_with("RECORD"))
267268
.with_copy_locks(state.copy_locks())
268269
.with_on_existing_directory(OnExistingDirectory::Merge);
269-
let used_link_mode = link_dir(wheel_path, site_packages, &options)?;
270+
let used_link_mode = link_dir(wheel, site_packages, &options)?;
270271

271272
if used_link_mode == LinkMode::Clone {
272273
// The directory mtime is not updated when cloning and the mtime is

0 commit comments

Comments
 (0)