Skip to content

Commit

Permalink
Allow symlinks to files in scripts directory
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 23, 2024
1 parent 76566b0 commit b2552bd
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions crates/install-wheel-rs/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,31 @@ fn install_script(
record: &mut [RecordEntry],
file: &DirEntry,
) -> Result<(), Error> {
if !file.file_type()?.is_file() {
let file_type = file.file_type()?;

if file_type.is_dir() {
return Err(Error::InvalidWheel(format!(
"Wheel contains entry in scripts directory that is not a file: {}",
file.path().display()
"Wheel contains an invalid entry (directory) in the `scripts` directory: {}",
file.path().simplified_display()
)));
}

if file_type.is_symlink() {
let Ok(target) = file.path().canonicalize() else {
return Err(Error::InvalidWheel(format!(
"Wheel contains an invalid entry (broken symlink) in the `scripts` directory: {}",
file.path().simplified_display(),
)));
};
if target.is_dir() {
return Err(Error::InvalidWheel(format!(
"Wheel contains an invalid entry (directory symlink) in the `scripts` directory: {} ({})",
file.path().simplified_display(),
target.simplified_display()
)));
}
}

let script_absolute = layout.scheme.scripts.join(file.file_name());
let script_relative =
pathdiff::diff_paths(&script_absolute, site_packages).ok_or_else(|| {
Expand Down

0 comments on commit b2552bd

Please sign in to comment.