Skip to content

Commit fd89f63

Browse files
astral-automations-bot[bot]github-actions[bot]konstin
authored
Add regression test for symlinks inside install directory (#21693)
Add a minimal integration test that reproduces #21692. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: konstin <[email protected]>
1 parent 000a665 commit fd89f63

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

‎crates/uv/tests/pip_install/pip_install.rs‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14443,6 +14443,63 @@ fn reject_symlinked_wheel_data_package_directory() -> Result<()> {
1444314443
Ok(())
1444414444
}
1444514445

14446+
/// Wheel data installation currently rejects a symlink that remains within the scheme root.
14447+
#[cfg(unix)]
14448+
#[test]
14449+
fn reject_in_prefix_symlinked_wheel_data_directory() -> Result<()> {
14450+
let context = uv_test::test_context!("3.11");
14451+
let wheel = context.temp_dir.join("foo-0.1.0-py3-none-any.whl");
14452+
let data_path = "foo-0.1.0.data/data/man/man1/foo.1";
14453+
let record = formatdoc! {"
14454+
foo-0.1.0.dist-info/METADATA,,
14455+
foo-0.1.0.dist-info/WHEEL,,
14456+
foo-0.1.0.dist-info/RECORD,,
14457+
{data_path},,
14458+
"};
14459+
14460+
let mut writer = ZipFileWriter::new(Vec::new());
14461+
for (name, contents) in [
14462+
(
14463+
"foo-0.1.0.dist-info/METADATA",
14464+
"Metadata-Version: 2.1\nName: foo\nVersion: 0.1.0\n",
14465+
),
14466+
(
14467+
"foo-0.1.0.dist-info/WHEEL",
14468+
"Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n",
14469+
),
14470+
("foo-0.1.0.dist-info/RECORD", record.as_str()),
14471+
(data_path, "foo manual\n"),
14472+
] {
14473+
let entry = ZipEntryBuilder::new(name.into(), Compression::Stored);
14474+
block_on(writer.write_entry_whole(entry, contents.as_bytes()))?;
14475+
}
14476+
fs_err::write(&wheel, block_on(writer.close())?)?;
14477+
14478+
fs_err::create_dir_all(context.venv.join("share/man"))?;
14479+
symlink("share/man", context.venv.join("man"))?;
14480+
14481+
// This link remains within the installation prefix, so rejecting the wheel is undesirable.
14482+
// See astral-sh/uv#21692.
14483+
uv_snapshot!(context.filters(), context.pip_install()
14484+
.arg("--link-mode")
14485+
.arg("copy")
14486+
.arg(&wheel), @"
14487+
exit_code: 2 (failure)
14488+
----- stderr -----
14489+
Resolved 1 package in [TIME]
14490+
Prepared 1 package in [TIME]
14491+
error: Failed to install: foo-0.1.0-py3-none-any.whl (foo==0.1.0 (from file://[TEMP_DIR]/foo-0.1.0-py3-none-any.whl))
14492+
cause: The wheel is invalid: Cannot install into symlinked directory: [VENV]/man
14493+
");
14494+
14495+
context
14496+
.venv
14497+
.child("share/man/man1/foo.1")
14498+
.assert(predicate::path::missing());
14499+
14500+
Ok(())
14501+
}
14502+
1444614503
/// Wheel headers must not be installed through a symlinked package destination.
1444714504
#[cfg(unix)]
1444814505
#[test]

0 commit comments

Comments
 (0)