mirror of https://github.com/astral-sh/uv
Make preview Python registration on Windows non-fatal (#14614)
Same as #14612 for registration with the Windows Registry.
This commit is contained in:
parent
bb1e9a247c
commit
d2c81e503f
|
|
@ -4954,6 +4954,17 @@ pub struct PythonInstallArgs {
|
||||||
#[arg(long, overrides_with("bin"), conflicts_with("default"))]
|
#[arg(long, overrides_with("bin"), conflicts_with("default"))]
|
||||||
pub no_bin: bool,
|
pub no_bin: bool,
|
||||||
|
|
||||||
|
/// Register the Python installation in the Windows registry.
|
||||||
|
///
|
||||||
|
/// This is the default behavior on Windows. If this flag is provided explicitly, uv will error if the
|
||||||
|
/// registry entry cannot be created.
|
||||||
|
#[arg(long, overrides_with("no_registry"), hide = true)]
|
||||||
|
pub registry: bool,
|
||||||
|
|
||||||
|
/// Do not register the Python installation in the Windows registry.
|
||||||
|
#[arg(long, overrides_with("registry"))]
|
||||||
|
pub no_registry: bool,
|
||||||
|
|
||||||
/// The Python version(s) to install.
|
/// The Python version(s) to install.
|
||||||
///
|
///
|
||||||
/// If not provided, the requested Python version(s) will be read from the `UV_PYTHON`
|
/// If not provided, the requested Python version(s) will be read from the `UV_PYTHON`
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ pub(crate) async fn install(
|
||||||
reinstall: bool,
|
reinstall: bool,
|
||||||
upgrade: bool,
|
upgrade: bool,
|
||||||
bin: Option<bool>,
|
bin: Option<bool>,
|
||||||
|
registry: Option<bool>,
|
||||||
force: bool,
|
force: bool,
|
||||||
python_install_mirror: Option<String>,
|
python_install_mirror: Option<String>,
|
||||||
pypy_install_mirror: Option<String>,
|
pypy_install_mirror: Option<String>,
|
||||||
|
|
@ -500,7 +501,7 @@ pub(crate) async fn install(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if preview.is_enabled() {
|
if preview.is_enabled() && !matches!(registry, Some(false)) {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
match uv_python::windows_registry::create_registry_entry(installation) {
|
match uv_python::windows_registry::create_registry_entry(installation) {
|
||||||
|
|
@ -670,11 +671,14 @@ pub(crate) async fn install(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
// If there are only bin install errors and the user didn't opt-in, we're only going to warn
|
// If there are only side-effect install errors and the user didn't opt-in, we're only going
|
||||||
let fatal = errors
|
// to warn
|
||||||
.iter()
|
let fatal = !errors.iter().all(|(kind, _, _)| match kind {
|
||||||
.all(|(kind, _, _)| matches!(kind, InstallErrorKind::Bin))
|
InstallErrorKind::Bin => bin.is_none(),
|
||||||
&& bin.is_none();
|
#[cfg(windows)]
|
||||||
|
InstallErrorKind::Registry => registry.is_none(),
|
||||||
|
InstallErrorKind::DownloadUnpack => false,
|
||||||
|
});
|
||||||
|
|
||||||
for (kind, key, err) in errors
|
for (kind, key, err) in errors
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
@ -691,10 +695,14 @@ pub(crate) async fn install(
|
||||||
(level, "install executable for")
|
(level, "install executable for")
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
InstallErrorKind::Registry => (
|
InstallErrorKind::Registry => {
|
||||||
"error".red().bold().to_string(),
|
let level = match registry {
|
||||||
"install registry entry for",
|
None => "warning".yellow().bold().to_string(),
|
||||||
),
|
Some(false) => continue,
|
||||||
|
Some(true) => "error".red().bold().to_string(),
|
||||||
|
};
|
||||||
|
(level, "install registry entry for")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
@ -714,11 +722,9 @@ pub(crate) async fn install(
|
||||||
}
|
}
|
||||||
|
|
||||||
if fatal {
|
if fatal {
|
||||||
return Ok(ExitStatus::Success);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(ExitStatus::Failure);
|
return Ok(ExitStatus::Failure);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(ExitStatus::Success)
|
Ok(ExitStatus::Success)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1403,6 +1403,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
||||||
args.reinstall,
|
args.reinstall,
|
||||||
upgrade,
|
upgrade,
|
||||||
args.bin,
|
args.bin,
|
||||||
|
args.registry,
|
||||||
args.force,
|
args.force,
|
||||||
args.python_install_mirror,
|
args.python_install_mirror,
|
||||||
args.pypy_install_mirror,
|
args.pypy_install_mirror,
|
||||||
|
|
@ -1432,6 +1433,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
||||||
reinstall,
|
reinstall,
|
||||||
upgrade,
|
upgrade,
|
||||||
args.bin,
|
args.bin,
|
||||||
|
args.registry,
|
||||||
args.force,
|
args.force,
|
||||||
args.python_install_mirror,
|
args.python_install_mirror,
|
||||||
args.pypy_install_mirror,
|
args.pypy_install_mirror,
|
||||||
|
|
|
||||||
|
|
@ -934,6 +934,7 @@ pub(crate) struct PythonInstallSettings {
|
||||||
pub(crate) reinstall: bool,
|
pub(crate) reinstall: bool,
|
||||||
pub(crate) force: bool,
|
pub(crate) force: bool,
|
||||||
pub(crate) bin: Option<bool>,
|
pub(crate) bin: Option<bool>,
|
||||||
|
pub(crate) registry: Option<bool>,
|
||||||
pub(crate) python_install_mirror: Option<String>,
|
pub(crate) python_install_mirror: Option<String>,
|
||||||
pub(crate) pypy_install_mirror: Option<String>,
|
pub(crate) pypy_install_mirror: Option<String>,
|
||||||
pub(crate) python_downloads_json_url: Option<String>,
|
pub(crate) python_downloads_json_url: Option<String>,
|
||||||
|
|
@ -964,6 +965,8 @@ impl PythonInstallSettings {
|
||||||
reinstall,
|
reinstall,
|
||||||
bin,
|
bin,
|
||||||
no_bin,
|
no_bin,
|
||||||
|
registry,
|
||||||
|
no_registry,
|
||||||
force,
|
force,
|
||||||
mirror: _,
|
mirror: _,
|
||||||
pypy_mirror: _,
|
pypy_mirror: _,
|
||||||
|
|
@ -977,6 +980,7 @@ impl PythonInstallSettings {
|
||||||
reinstall,
|
reinstall,
|
||||||
force,
|
force,
|
||||||
bin: flag(bin, no_bin, "bin"),
|
bin: flag(bin, no_bin, "bin"),
|
||||||
|
registry: flag(registry, no_registry, "registry"),
|
||||||
python_install_mirror: python_mirror,
|
python_install_mirror: python_mirror,
|
||||||
pypy_install_mirror: pypy_mirror,
|
pypy_install_mirror: pypy_mirror,
|
||||||
python_downloads_json_url,
|
python_downloads_json_url,
|
||||||
|
|
@ -992,6 +996,7 @@ pub(crate) struct PythonUpgradeSettings {
|
||||||
pub(crate) install_dir: Option<PathBuf>,
|
pub(crate) install_dir: Option<PathBuf>,
|
||||||
pub(crate) targets: Vec<String>,
|
pub(crate) targets: Vec<String>,
|
||||||
pub(crate) force: bool,
|
pub(crate) force: bool,
|
||||||
|
pub(crate) registry: Option<bool>,
|
||||||
pub(crate) python_install_mirror: Option<String>,
|
pub(crate) python_install_mirror: Option<String>,
|
||||||
pub(crate) pypy_install_mirror: Option<String>,
|
pub(crate) pypy_install_mirror: Option<String>,
|
||||||
pub(crate) python_downloads_json_url: Option<String>,
|
pub(crate) python_downloads_json_url: Option<String>,
|
||||||
|
|
@ -1019,6 +1024,7 @@ impl PythonUpgradeSettings {
|
||||||
let force = false;
|
let force = false;
|
||||||
let default = false;
|
let default = false;
|
||||||
let bin = None;
|
let bin = None;
|
||||||
|
let registry = None;
|
||||||
|
|
||||||
let PythonUpgradeArgs {
|
let PythonUpgradeArgs {
|
||||||
install_dir,
|
install_dir,
|
||||||
|
|
@ -1032,6 +1038,7 @@ impl PythonUpgradeSettings {
|
||||||
install_dir,
|
install_dir,
|
||||||
targets,
|
targets,
|
||||||
force,
|
force,
|
||||||
|
registry,
|
||||||
python_install_mirror: python_mirror,
|
python_install_mirror: python_mirror,
|
||||||
pypy_install_mirror: pypy_mirror,
|
pypy_install_mirror: pypy_mirror,
|
||||||
python_downloads_json_url,
|
python_downloads_json_url,
|
||||||
|
|
|
||||||
|
|
@ -507,6 +507,9 @@ fn help_subsubcommand() {
|
||||||
--no-bin
|
--no-bin
|
||||||
Do not install a Python executable into the `bin` directory
|
Do not install a Python executable into the `bin` directory
|
||||||
|
|
||||||
|
--no-registry
|
||||||
|
Do not register the Python installation in the Windows registry
|
||||||
|
|
||||||
--mirror <MIRROR>
|
--mirror <MIRROR>
|
||||||
Set the URL to use as the source for downloading Python installations.
|
Set the URL to use as the source for downloading Python installations.
|
||||||
|
|
||||||
|
|
@ -795,6 +798,8 @@ fn help_flag_subsubcommand() {
|
||||||
The directory to store the Python installation in [env: UV_PYTHON_INSTALL_DIR=]
|
The directory to store the Python installation in [env: UV_PYTHON_INSTALL_DIR=]
|
||||||
--no-bin
|
--no-bin
|
||||||
Do not install a Python executable into the `bin` directory
|
Do not install a Python executable into the `bin` directory
|
||||||
|
--no-registry
|
||||||
|
Do not register the Python installation in the Windows registry
|
||||||
--mirror <MIRROR>
|
--mirror <MIRROR>
|
||||||
Set the URL to use as the source for downloading Python installations [env:
|
Set the URL to use as the source for downloading Python installations [env:
|
||||||
UV_PYTHON_INSTALL_MIRROR=]
|
UV_PYTHON_INSTALL_MIRROR=]
|
||||||
|
|
|
||||||
|
|
@ -2804,6 +2804,7 @@ uv python install [OPTIONS] [TARGETS]...
|
||||||
<p>May also be set with the <code>UV_NO_MANAGED_PYTHON</code> environment variable.</p></dd><dt id="uv-python-install--no-progress"><a href="#uv-python-install--no-progress"><code>--no-progress</code></a></dt><dd><p>Hide all progress outputs.</p>
|
<p>May also be set with the <code>UV_NO_MANAGED_PYTHON</code> environment variable.</p></dd><dt id="uv-python-install--no-progress"><a href="#uv-python-install--no-progress"><code>--no-progress</code></a></dt><dd><p>Hide all progress outputs.</p>
|
||||||
<p>For example, spinners or progress bars.</p>
|
<p>For example, spinners or progress bars.</p>
|
||||||
<p>May also be set with the <code>UV_NO_PROGRESS</code> environment variable.</p></dd><dt id="uv-python-install--no-python-downloads"><a href="#uv-python-install--no-python-downloads"><code>--no-python-downloads</code></a></dt><dd><p>Disable automatic downloads of Python.</p>
|
<p>May also be set with the <code>UV_NO_PROGRESS</code> environment variable.</p></dd><dt id="uv-python-install--no-python-downloads"><a href="#uv-python-install--no-python-downloads"><code>--no-python-downloads</code></a></dt><dd><p>Disable automatic downloads of Python.</p>
|
||||||
|
</dd><dt id="uv-python-install--no-registry"><a href="#uv-python-install--no-registry"><code>--no-registry</code></a></dt><dd><p>Do not register the Python installation in the Windows registry</p>
|
||||||
</dd><dt id="uv-python-install--offline"><a href="#uv-python-install--offline"><code>--offline</code></a></dt><dd><p>Disable network access.</p>
|
</dd><dt id="uv-python-install--offline"><a href="#uv-python-install--offline"><code>--offline</code></a></dt><dd><p>Disable network access.</p>
|
||||||
<p>When disabled, uv will only use locally cached data and locally available files.</p>
|
<p>When disabled, uv will only use locally cached data and locally available files.</p>
|
||||||
<p>May also be set with the <code>UV_OFFLINE</code> environment variable.</p></dd><dt id="uv-python-install--project"><a href="#uv-python-install--project"><code>--project</code></a> <i>project</i></dt><dd><p>Run the command within the given project directory.</p>
|
<p>May also be set with the <code>UV_OFFLINE</code> environment variable.</p></dd><dt id="uv-python-install--project"><a href="#uv-python-install--project"><code>--project</code></a> <i>project</i></dt><dd><p>Run the command within the given project directory.</p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue