feat(conda): allow configuring additional envs to update (#1048)

This commit is contained in:
Max Kapur
2025-07-15 06:15:42 -05:00
committed by GitHub
parent 6b8327faad
commit 6719ff93d8
3 changed files with 69 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ use regex::bytes::Regex;
use rust_i18n::t;
use semver::Version;
use std::ffi::OsString;
use std::iter::once;
use std::path::PathBuf;
use std::process::Command;
use std::sync::LazyLock;
@@ -565,13 +566,33 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
print_separator("Conda");
let mut command = ctx.run_type().execute(&conda);
command.args(["update", "--all", "-n", "base"]);
if ctx.config().yes(Step::Conda) {
command.arg("--yes");
}
command.status_checked()?;
// Update named environments, starting with the always-present "base"
let base_env_name = "base".to_string();
let addl_env_names = ctx.config().conda_env_names().into_iter().flatten();
let env_names = once(&base_env_name).chain(addl_env_names);
for env_name in env_names {
let mut command = ctx.run_type().execute(&conda);
command.args(["update", "--all", "-n", env_name]);
if ctx.config().yes(Step::Conda) {
command.arg("--yes");
}
command.status_checked()?;
}
// Update any environments given by path
if let Some(env_paths) = ctx.config().conda_env_paths() {
for env_path in env_paths.iter() {
let mut command = ctx.run_type().execute(&conda);
command.args(["update", "--all", "-p", env_path]);
if ctx.config().yes(Step::Conda) {
command.arg("--yes");
}
command.status_checked()?;
}
}
// Cleanup (conda clean) is global (not tied to a particular environment)
if ctx.config().cleanup() {
let mut command = ctx.run_type().execute(conda);
command.args(["clean", "--all"]);