-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send installer output to stderr (#47)
- Loading branch information
Showing
6 changed files
with
80 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
use anyhow::Result; | ||
use anyhow::{anyhow, Result}; | ||
use std::process::{Command, Stdio}; | ||
|
||
pub trait Installer { | ||
fn install(&self, to_dir: &std::path::Path) -> Result<()>; | ||
fn describe(&self) -> String; | ||
} | ||
|
||
pub fn run_subcommand_for_installer<'a>( | ||
command: &str, | ||
args: impl Iterator<Item = &'a str>, | ||
env: impl Iterator<Item = (&'a str, &'a str)>, | ||
) -> Result<()> { | ||
let mut command = Command::new(command); | ||
// Directing /dev/null to stdin breaks Conda's progress bar, for some reason | ||
// command.stdin(Stdio::null()) | ||
command.stderr(Stdio::inherit()); | ||
command.stdout(os_pipe::dup_stderr()?); | ||
|
||
for (env_key, env_val) in env { | ||
command.env(env_key, env_val); | ||
} | ||
|
||
for arg in args { | ||
command.arg(arg); | ||
} | ||
|
||
let mut output = command.spawn().unwrap(); | ||
if !output.wait()?.success() { | ||
return Err(anyhow!( | ||
"Installer subcommand {:?} exited with error", | ||
command | ||
)); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters