Skip to content

Commit

Permalink
Allow dashes and underscores in custom index names (#8339)
Browse files Browse the repository at this point in the history
Previously, `uv add --index` command threw an error when the index name
included characters like hyphens or underscores.

Closes #8315
  • Loading branch information
vinibrsl authored Oct 18, 2024
1 parent c162078 commit 69d5e08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/uv-distribution-types/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ impl FromStr for Index {
return Err(IndexSourceError::EmptyName);
}

if name.chars().all(char::is_alphanumeric) {
if name
.chars()
.all(|c| c.is_alphanumeric() || c == '-' || c == '_')
{
let url = IndexUrl::from_str(url)?;
return Ok(Self {
name: Some(name.to_string()),
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration/indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ name = "pytorch"
url = "https://download.pytorch.org/whl/cpu"
```

Index names must only contain alphanumeric characters, dashes, or underscores.

Indexes are prioritized in the order in which they’re defined, such that the first index listed in
the configuration file is the first index consulted when resolving dependencies, with indexes
provided via the command line taking precedence over those in the configuration file.
Expand Down

0 comments on commit 69d5e08

Please sign in to comment.