Expand environment variables in user-provided index URLs#13879
Expand environment variables in user-provided index URLs#13879msabramo wants to merge 5 commits intoastral-sh:mainfrom
Conversation
e2f68b3 to
1dbd9ec
Compare
1dbd9ec to
65ad2bd
Compare
65ad2bd to
acf7189
Compare
acf7189 to
c938a55
Compare
by running `cargo dev generate-options-reference`
|
Windows test failed with what looks to be an intermittent failure downloading Python: |
to see if failing Windows GitHub action passes this time.
Adding an empty commit to force a rerun fixed this temporary issue, though maybe it might be good to add retry logic for this? Anyway, all tests passing now! 🎉 |
|
Thanks for the pull request. As a brief note, we do not have consensus on a design for this and are very unlikely to accept a pull request without reaching that consensus first. We may be able to use this proposal to help drive consensus forward, but I want to set the right expectations here. |
Yeah understood, I know this is kind of controversial. I was just composing a comment on the issue with a proposal about how to solve some of the concerns. That proposal is not implemented in this PR, but if by discussion we come to some solution that people are happy with, then I could add it to this PR. |

Fixes: GH-5734
Summary
This PR adds support for environment variable expansion in
[[tool.uv.index]]configuration URLs, enabling dynamic and secure index configuration.What it does:
urlandpublish-urlfields using${VARIABLE}and${VARIABLE:-default}syntax~) expansion for home directory pathspyproject.tomlImplementation details:
shellexpandcrate dependency for robust environment variable and tilde expansionDeserializefor theIndexstruct to perform expansion during TOML parsingExample usage:
Test Plan
Unit tests:
test_index_environment_variable_expansion: Verifies${VAR}syntax expansion with set environment variablestest_index_without_environment_variables: Ensures existing configurations without env vars continue to worktest_index_missing_environment_variable: Tests error handling when required environment variables are missingtest_index_tilde_expansion: Verifies~home directory expansion works correctlyIntegration testing:
/Users/abramowi/Code/OpenSource/uv/target/release/uv syncin a project that had something like:uv syncwhich failed:cargo build --release$ /Users/abramowi/Code/OpenSource/uv/target/release/uv sync -v | grep artifactoryand got:Compatibility testing:
cargo test -p uv-distribution-typestests passDocumentation:
docs/concepts/indexes.mdwith environment variable expansion section and examplesdocs/guides/integration/alternative-indexes.mdwith env var examples for Azure, GCP, and AWSdocs/reference/settings.mdwith comprehensive examples and feature description