Respect --index-url provided via requirements.txt (#1719)

## Summary

When we read `--index-url` from a `requirements.txt`, we attempt to
respect the `--index-url` provided by the CLI if it exists.
Unfortunately, `--index-url` from the CLI has a default value... so we
_never_ respect the `--index-url` in the requirements file.

This PR modifies the CLI to use `None`, and moves the default into logic
in the `IndexLocations `struct.

Closes https://github.com/astral-sh/uv/issues/1692.
This commit is contained in:
Charlie Marsh 2024-02-19 19:02:26 -05:00 committed by GitHub
parent 7b2c93f9fb
commit 034f62b24f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 153 additions and 55 deletions

View file

@ -56,8 +56,12 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
let platform = Platform::current()?;
let venv = Virtualenv::from_env(platform, &cache)?;
let index_locations =
IndexLocations::from_args(args.index_url, args.extra_index_url, args.find_links, false);
let index_locations = IndexLocations::new(
Some(args.index_url),
args.extra_index_url,
args.find_links,
false,
);
let client = RegistryClientBuilder::new(cache.clone())
.index_urls(index_locations.index_urls())
.build();