Support environment variables in index URLs in requirements files (#2036)

## Summary

This also preserves the environment variables in the output file, e.g.:

```
Resolved 1 package in 216ms
# This file was autogenerated by uv via the following command:
#    uv pip compile requirements.in --emit-index-url
--index-url https://test.pypi.org/${SUFFIX}

requests==2.5.4.1
```

I'm torn on whether that's correct or undesirable here.

Closes #2035.
This commit is contained in:
Charlie Marsh 2024-02-28 14:36:20 -05:00 committed by GitHub
parent 1df977f86b
commit b873e3e991
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 140 additions and 70 deletions

View file

@ -6,6 +6,7 @@ use rustc_hash::FxHashMap;
use distribution_types::{CachedRegistryDist, FlatIndexLocation, IndexLocations, IndexUrl};
use pep440_rs::Version;
use pep508_rs::VerbatimUrl;
use platform_tags::Tags;
use uv_cache::{Cache, CacheBucket, WheelCache};
use uv_fs::{directories, symlinks};
@ -83,7 +84,9 @@ impl<'a> RegistryWheelIndex<'a> {
.flat_index()
.filter_map(|flat_index| match flat_index {
FlatIndexLocation::Path(_) => None,
FlatIndexLocation::Url(url) => Some(IndexUrl::Url(url.clone())),
FlatIndexLocation::Url(url) => {
Some(IndexUrl::Url(VerbatimUrl::unknown(url.clone())))
}
})
.collect();