mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 18:38:21 +00:00
Respect PEP 723 script lockfiles in uv run (#10136)
## Summary If a script has a lockfile, then `uv run` will now reuse it. Closes https://github.com/astral-sh/uv/issues/7483. Closes https://github.com/astral-sh/uv/issues/9688.
This commit is contained in:
parent
391ab757b8
commit
e22b728e3f
10 changed files with 658 additions and 267 deletions
|
@ -54,6 +54,14 @@ impl Pep723Item {
|
|||
Self::Remote(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the PEP 723 script, if any.
|
||||
pub fn as_script(&self) -> Option<&Pep723Script> {
|
||||
match self {
|
||||
Self::Script(script) => Some(script),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to a PEP 723 item.
|
||||
|
@ -234,6 +242,18 @@ impl Pep723Script {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Return the [`Sources`] defined in the PEP 723 metadata.
|
||||
pub fn sources(&self) -> &BTreeMap<PackageName, Sources> {
|
||||
static EMPTY: BTreeMap<PackageName, Sources> = BTreeMap::new();
|
||||
|
||||
self.metadata
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.unwrap_or(&EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
/// PEP 723 metadata as parsed from a `script` comment block.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue