Show user-facing warning when falling back to copy installs (#4880)

## Summary

This has come up a few times including in a recent email to me.
This commit is contained in:
Charlie Marsh 2024-07-08 08:35:58 -05:00 committed by GitHub
parent 947cfa13a8
commit 4f340580c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 5 deletions

1
Cargo.lock generated
View file

@ -1854,6 +1854,7 @@ dependencies = [
"tracing",
"uv-fs",
"uv-normalize",
"uv-warnings",
"walkdir",
"zip",
]

View file

@ -23,9 +23,10 @@ name = "install_wheel_rs"
distribution-filename = { workspace = true }
pep440_rs = { workspace = true }
platform-tags = { workspace = true }
uv-normalize = { workspace = true }
uv-fs = { workspace = true }
pypi-types = { workspace = true }
uv-fs = { workspace = true }
uv-normalize = { workspace = true }
uv-warnings = { workspace = true }
clap = { workspace = true, optional = true, features = ["derive"] }
configparser = { workspace = true }

View file

@ -16,6 +16,7 @@ use distribution_filename::WheelFilename;
use pep440_rs::Version;
use pypi_types::DirectUrl;
use uv_normalize::PackageName;
use uv_warnings::warn_user_once;
use crate::script::{scripts_from_ini, Script};
use crate::wheel::{
@ -355,7 +356,8 @@ fn clone_recursive(
debug!(
"Failed to clone `{}` to temporary location `{}`, attempting to copy files as a fallback",
from.display(),
tempfile.display());
tempfile.display(),
);
*attempt = Attempt::UseCopyFallback;
fs::copy(&from, &to)?;
}
@ -401,6 +403,7 @@ fn clone_recursive(
} else {
fs::copy(&from, &to)?;
}
warn_user_once!("Failed to clone files; falling back to full copy. This may lead to degraded performance. If this is intentional, use `--link-mode=copy` to suppress this warning.\n\nhint: If the cache and target directories are on different filesystems, reflinking may not be supported.");
}
}
@ -524,6 +527,7 @@ fn hardlink_wheel_files(
}
Attempt::UseCopyFallback => {
fs::copy(path, &out_path)?;
warn_user_once!("Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If this is intentional, use `--link-mode=copy` to suppress this warning.\n\nhint: If the cache and target directories are on different filesystems, hardlinking may not be supported.");
}
}

View file

@ -5104,6 +5104,10 @@ fn target_no_build_isolation() -> Result<()> {
/// Sync to a `--prefix` directory.
#[test]
#[cfg_attr(
target_os = "macos",
ignore = "On macOS, we fail to reflink due to a non-existent site-packages directory"
)]
fn prefix() -> Result<()> {
let context = TestContext::new("3.12");
@ -5111,10 +5115,12 @@ fn prefix() -> Result<()> {
let requirements_in = context.temp_dir.child("requirements.in");
requirements_in.write_str("iniconfig==2.0.0")?;
let prefix = context.temp_dir.child("prefix");
uv_snapshot!(context.pip_sync()
.arg("requirements.in")
.arg("--prefix")
.arg("prefix"), @r###"
.arg(prefix.path()), @r###"
success: true
exit_code: 0
----- stdout -----
@ -5149,7 +5155,7 @@ fn prefix() -> Result<()> {
uv_snapshot!(context.pip_sync()
.arg("requirements.in")
.arg("--prefix")
.arg("prefix"), @r###"
.arg(prefix.path()), @r###"
success: true
exit_code: 0
----- stdout -----