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
11 changes: 9 additions & 2 deletions crates/install-wheel-rs/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,17 @@ fn clone_wheel_files(
let mut count = 0usize;
let mut attempt = Attempt::default();

// On macOS, directly can be recursively copied with a single `clonefile` call.
// On macOS, directories can be recursively copied with a single `clonefile` call.
// So we only need to iterate over the top-level of the directory, and copy each file or
// subdirectory unless the subdirectory exists already in which case we'll need to recursively
// merge its contents with the existing directory.
//
// On linux, we need to always reflink recursively, as `FICLONE` ioctl does not support directories.
// Also note, that reflink is only supported on certain filesystems (btrfs, xfs, ...), and only when
// it does not cross filesystem boundaries.
//
// On windows, we also always need to reflink recursively, as `FSCTL_DUPLICATE_EXTENTS_TO_FILE` ioctl
// is not supported on directories. Also, it is only supported on certain filesystems (ReFS, SMB, ...).
for entry in fs::read_dir(wheel.as_ref())? {
clone_recursive(
site_packages.as_ref(),
Expand Down Expand Up @@ -365,7 +372,7 @@ fn clone_recursive(

debug!("Cloning {} to {}", from.display(), to.display());

if cfg!(windows) && from.is_dir() {
if (cfg!(windows) || cfg!(target_os = "linux")) && from.is_dir() {
// On Windows, reflinking directories is not supported, so we copy each file instead.
fs::create_dir_all(&to)?;
for entry in fs::read_dir(from)? {
Expand Down