Skip to content

Commit 58b5fd4

Browse files
Add tool.uv.sources to the "Settings" reference (#8543)
## Summary Closes #8540.
1 parent 99a8746 commit 58b5fd4

File tree

5 files changed

+81
-6
lines changed

5 files changed

+81
-6
lines changed

crates/uv-dev/src/generate_cli_reference.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ fn generate() -> String {
101101
generate_command(&mut output, &uv, &mut parents);
102102

103103
for (value, replacement) in REPLACEMENTS {
104-
output = output.replace(value, replacement);
104+
assert_ne!(
105+
value, replacement,
106+
"`value` and `replacement` must be different, but both are `{value}`"
107+
);
108+
let before = &output;
109+
let after = output.replace(value, replacement);
110+
assert_ne!(*before, after, "Could not find `{value}` in the output");
111+
output = after;
105112
}
106113

107114
output

crates/uv-dev/src/generate_json_schema.rs

+29-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub(crate) struct Args {
3333
}
3434

3535
pub(crate) fn main(args: &Args) -> Result<()> {
36-
let schema = schema_for!(CombinedOptions);
37-
let schema_string = serde_json::to_string_pretty(&schema).unwrap();
36+
// Generate the schema.
37+
let schema_string = generate();
3838
let filename = "uv.schema.json";
3939
let schema_path = PathBuf::from(ROOT_DIR).join(filename);
4040

@@ -80,5 +80,32 @@ pub(crate) fn main(args: &Args) -> Result<()> {
8080
Ok(())
8181
}
8282

83+
const REPLACEMENTS: &[(&str, &str)] = &[
84+
// Use the fully-resolved URL rather than the relative Markdown path.
85+
(
86+
"(../concepts/dependencies.md)",
87+
"(https://docs.astral.sh/uv/concepts/dependencies/)",
88+
),
89+
];
90+
91+
/// Generate the JSON schema for the combined options as a string.
92+
fn generate() -> String {
93+
let schema = schema_for!(CombinedOptions);
94+
let mut output = serde_json::to_string_pretty(&schema).unwrap();
95+
96+
for (value, replacement) in REPLACEMENTS {
97+
assert_ne!(
98+
value, replacement,
99+
"`value` and `replacement` must be different, but both are `{value}`"
100+
);
101+
let before = &output;
102+
let after = output.replace(value, replacement);
103+
assert_ne!(*before, after, "Could not find `{value}` in the output");
104+
output = after;
105+
}
106+
107+
output
108+
}
109+
83110
#[cfg(test)]
84111
mod tests;

crates/uv-workspace/src/pyproject.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,23 @@ pub struct Tool {
152152
#[serde(rename_all = "kebab-case")]
153153
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
154154
pub struct ToolUv {
155-
/// The sources to use (e.g., workspace members, Git repositories, local paths) when resolving
156-
/// dependencies.
155+
/// The sources to use when resolving dependencies.
156+
///
157+
/// `tool.uv.sources` enriches the dependency metadata with additional sources, incorporated
158+
/// during development. A dependency source can be a Git repository, a URL, a local path, or an
159+
/// alternative registry.
160+
///
161+
/// See [Dependencies](../concepts/dependencies.md) for more.
162+
#[option(
163+
default = "\"[]\"",
164+
value_type = "dict",
165+
example = r#"
166+
[tool.uv.sources]
167+
httpx = { git = "https://github.com/encode/httpx", tag = "0.27.0" }
168+
pytest = { url = "https://files.pythonhosted.org/packages/6b/77/7440a06a8ead44c7757a64362dd22df5760f9b12dc5f11b6188cd2fc27a0/pytest-8.3.3-py3-none-any.whl" }
169+
pydantic = { path = "/path/to/pydantic", editable = true }
170+
"#
171+
)]
157172
pub sources: Option<ToolUvSources>,
158173

159174
/// The indexes to use when resolving dependencies.

docs/reference/settings.md

+26
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,32 @@ package = false
198198

199199
---
200200

201+
### [`sources`](#sources) {: #sources }
202+
203+
The sources to use when resolving dependencies.
204+
205+
`tool.uv.sources` enriches the dependency metadata with additional sources, incorporated
206+
during development. A dependency source can be a Git repository, a URL, a local path, or an
207+
alternative registry.
208+
209+
See [Dependencies](../concepts/dependencies.md) for more.
210+
211+
**Default value**: `"[]"`
212+
213+
**Type**: `dict`
214+
215+
**Example usage**:
216+
217+
```toml title="pyproject.toml"
218+
219+
[tool.uv.sources]
220+
httpx = { git = "https://github.com/encode/httpx", tag = "0.27.0" }
221+
pytest = { url = "https://files.pythonhosted.org/packages/6b/77/7440a06a8ead44c7757a64362dd22df5760f9b12dc5f11b6188cd2fc27a0/pytest-8.3.3-py3-none-any.whl" }
222+
pydantic = { path = "/path/to/pydantic", editable = true }
223+
```
224+
225+
---
226+
201227
### `workspace`
202228

203229
#### [`exclude`](#workspace_exclude) {: #workspace_exclude }

uv.schema.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)