mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 18:38:21 +00:00
Discover and respect .python-version
files in parent directories (#6370)
Uses #6369 for test coverage. Updates version file discovery to search up into parent directories. Also refactors Python request determination to avoid duplicating the user request / version file / workspace lookup logic in every command (this supersedes the work started in https://github.com/astral-sh/uv/pull/6372). There is a bit of remaining work here, mostly around documentation. There are some edge-cases where we don't use the refactored request utility, like `uv build` — I'm not sure how I'm going to handle that yet as it needs a separate root directory.
This commit is contained in:
parent
fb89b64acf
commit
8ef5949294
23 changed files with 807 additions and 252 deletions
|
@ -44,10 +44,19 @@ impl Pep723Item {
|
|||
Self::Remote(metadata) => metadata,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the path of the PEP 723 item, if any.
|
||||
pub fn path(&self) -> Option<&Path> {
|
||||
match self {
|
||||
Self::Script(script) => Some(&script.path),
|
||||
Self::Stdin(_) => None,
|
||||
Self::Remote(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A PEP 723 script, including its [`Pep723Metadata`].
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Pep723Script {
|
||||
/// The path to the Python script.
|
||||
pub path: PathBuf,
|
||||
|
@ -188,7 +197,7 @@ impl Pep723Script {
|
|||
/// PEP 723 metadata as parsed from a `script` comment block.
|
||||
///
|
||||
/// See: <https://peps.python.org/pep-0723/>
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Pep723Metadata {
|
||||
pub dependencies: Option<Vec<uv_pep508::Requirement<VerbatimParsedUrl>>>,
|
||||
|
@ -248,13 +257,13 @@ impl FromStr for Pep723Metadata {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Tool {
|
||||
pub uv: Option<ToolUv>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ToolUv {
|
||||
#[serde(flatten)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue