Skip to content

Commit

Permalink
Run conda env update -p and -n according to config
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkapur committed Feb 21, 2025
1 parent 097063f commit ccecbbf
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(unused_imports)]

use std::ffi::OsStr;
use std::iter::once;
use std::path::PathBuf;
use std::process::Command;
use std::{env, path::Path};
Expand Down Expand Up @@ -517,12 +518,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");
// 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()?;
}
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()?;
}
}

Ok(())
}

pub fn run_pixi_update(ctx: &ExecutionContext) -> Result<()> {
Expand Down

0 comments on commit ccecbbf

Please sign in to comment.