From 1218766ea59bca383f68b2c622a8964cf55909eb Mon Sep 17 00:00:00 2001 From: Bas Schoenmaeckers <7943856+bschoenmaeckers@users.noreply.github.com> Date: Mon, 13 May 2024 18:03:39 +0200 Subject: [PATCH] Clone individual files on windows ReFS (#3551) Windows does not support cloning whole directories so clone each file instead. closes #3547 ## Test Plan Ran ` uv pip install setuptools --link-mode=clone` manually --- crates/install-wheel-rs/src/linker.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/install-wheel-rs/src/linker.rs b/crates/install-wheel-rs/src/linker.rs index 7a084c6d3318..8c0a2be8fbda 100644 --- a/crates/install-wheel-rs/src/linker.rs +++ b/crates/install-wheel-rs/src/linker.rs @@ -327,6 +327,15 @@ fn clone_recursive( debug!("Cloning {} to {}", from.display(), to.display()); + if cfg!(windows) && 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)? { + clone_recursive(site_packages, wheel, &entry?, attempt)?; + } + return Ok(()); + } + match attempt { Attempt::Initial => { if let Err(err) = reflink::reflink(&from, &to) {