Don't install incompatible path and url wheels (#739)

Add early tag checking for path and url wheels.

This does not check for resolve for consistency with index wheels.
This commit is contained in:
konsti 2024-01-02 16:00:50 +01:00 committed by GitHub
parent cd43708369
commit a3d8b3d9ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 0 deletions

View file

@ -2475,3 +2475,43 @@ fn sync_editable_and_registry() -> Result<()> {
Ok(())
}
#[test]
fn incompatible_wheel() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
let wheel_dir = assert_fs::TempDir::new()?;
let cache_dir = assert_fs::TempDir::new()?;
let venv = create_venv_py312(&temp_dir, &cache_dir);
let wheel = wheel_dir.child("foo-1.2.3-not-compatible-wheel.whl");
wheel.touch()?;
let requirements_txt = temp_dir.child("requirements.txt");
requirements_txt.write_str(&format!("foo @ file://{}", wheel.path().display()))?;
let mut filters = INSTA_FILTERS.to_vec();
let wheel_dir = wheel_dir.path().display().to_string();
filters.push((&wheel_dir, "[TEMP_DIR]"));
insta::with_settings!({
filters => filters
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-sync")
.arg("requirements.txt")
.arg("--cache-dir")
.arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str())
.current_dir(&temp_dir), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: Failed to determine installation plan
Caused by: A path dependency is incompatible with the current platform: [TEMP_DIR]/foo-1.2.3-not-compatible-wheel.whl
"###);
});
Ok(())
}