Add support for upgrading Python in tool environments (#7605)

This PR adds support for upgrading the build environment of tools with
the addition of a ```--python``` argument to ```uv upgrade```, as
specified in #7471.

Some things to note:
- I added support for individual packages — I didn't think there was a
good reason for ```--python``` to only apply to all packages
- Upgrading with ```--python``` also upgrades the package itself — I
think this is fair as if a user wants to _strictly_ switch the version
of Python being used to build a tool's environment they can use ```uv
install```. This behavior can of course be modified if others don't
agree!

Closes https://github.com/astral-sh/uv/issues/6297.

Closes https://github.com/astral-sh/uv/issues/7471.
This commit is contained in:
tfsingh
2024-09-25 10:40:28 -07:00
committed by GitHub
parent f5601e2610
commit 106633a5e5
10 changed files with 394 additions and 53 deletions
+14
View File
@@ -3396,6 +3396,20 @@ pub struct ToolUpgradeArgs {
#[arg(long, conflicts_with("name"))]
pub all: bool,
/// Upgrade a tool, and specify it to use the given Python interpreter
/// to build its environment. Use with `--all` to apply to all tools.
///
/// See `uv help python` for details on Python discovery and supported
/// request formats.
#[arg(
long,
short,
env = "UV_PYTHON",
verbatim_doc_comment,
help_heading = "Python options"
)]
pub python: Option<String>,
#[command(flatten)]
pub installer: ResolverInstallerArgs,