Respect --no-build and --no-binary in --find-links (#2826)

## Summary

In working on `--require-hashes`, I noticed that we're missing some
incompatibility tracking for `--find-links` distributions. Specifically,
we don't respect `--no-build` or `--no-binary`, so if we select a wheel
due to `--find-links`, we then throw a hard error when trying to build
it later (if `--no-binary` is provided), rather than selecting the
source distribution instead.

Closes https://github.com/astral-sh/uv/issues/2827.
This commit is contained in:
Charlie Marsh 2024-04-04 22:00:39 -04:00 committed by GitHub
parent 365cb16fd6
commit 2ac562b40d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 150 additions and 43 deletions

View file

@ -56,14 +56,6 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
let venv = PythonEnvironment::from_virtualenv(&cache)?;
let index_locations =
IndexLocations::new(args.index_url, args.extra_index_url, args.find_links, false);
let client = RegistryClientBuilder::new(cache.clone())
.index_urls(index_locations.index_urls())
.build();
let flat_index = {
let client = FlatIndexClient::new(&client, &cache);
let entries = client.fetch(index_locations.flat_index()).await?;
FlatIndex::from_entries(entries, venv.interpreter().tags()?)
};
let index = InMemoryIndex::default();
let in_flight = InFlight::default();
let no_build = if args.no_build {
@ -71,6 +63,19 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
} else {
NoBuild::None
};
let client = RegistryClientBuilder::new(cache.clone())
.index_urls(index_locations.index_urls())
.build();
let flat_index = {
let client = FlatIndexClient::new(&client, &cache);
let entries = client.fetch(index_locations.flat_index()).await?;
FlatIndex::from_entries(
entries,
venv.interpreter().tags()?,
&no_build,
&NoBinary::None,
)
};
let config_settings = ConfigSettings::default();
let build_dispatch = BuildDispatch::new(