Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/pet-conda/src/conda_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use log::{error, trace, warn};
use pet_fs::path::resolve_symlink;
use pet_python_utils::executable::new_silent_command;
use std::path::PathBuf;

#[derive(Debug, serde::Deserialize)]
Expand Down Expand Up @@ -45,7 +46,7 @@ impl CondaInfo {
resolve_symlink(&executable).unwrap_or(executable)
};

let result = std::process::Command::new(&executable)
let result = new_silent_command(&executable)
.arg("info")
.arg("--json")
.output();
Expand Down
3 changes: 2 additions & 1 deletion crates/pet-poetry/src/environment_locations_spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use lazy_static::lazy_static;
use log::{error, trace};
use pet_core::python_environment::PythonEnvironment;
use pet_python_utils::executable::new_silent_command;
use regex::Regex;
use std::{path::PathBuf, time::SystemTime};

Expand Down Expand Up @@ -36,7 +37,7 @@ pub fn list_environments(

fn get_environments(executable: &PathBuf, workspace_dir: &PathBuf) -> Option<Vec<PathBuf>> {
let start = SystemTime::now();
let result = std::process::Command::new(executable)
let result = new_silent_command(executable)
.arg("env")
.arg("list")
.arg("--full-path")
Expand Down
4 changes: 2 additions & 2 deletions crates/pet-python-utils/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
time::SystemTime,
};

use crate::cache::create_cache;
use crate::{cache::create_cache, executable::new_silent_command};

const PYTHON_INFO_JSON_SEPARATOR: &str = "093385e9-59f7-4a16-a604-14bf206256fe";
const PYTHON_INFO_CMD:&str = "import json, sys; print('093385e9-59f7-4a16-a604-14bf206256fe');print(json.dumps({'version': '.'.join(str(n) for n in sys.version_info), 'sys_prefix': sys.prefix, 'executable': sys.executable, 'is64_bit': sys.maxsize > 2**32}))";
Expand Down Expand Up @@ -92,7 +92,7 @@ fn get_interpreter_details(executable: &Path) -> Option<ResolvedPythonEnv> {
let executable = executable.to_str()?;
let start = SystemTime::now();
trace!("Executing Python: {} -c {}", executable, PYTHON_INFO_CMD);
let result = std::process::Command::new(executable)
let result = new_silent_command(executable)
.args(["-c", PYTHON_INFO_CMD])
.output();
match result {
Expand Down
17 changes: 17 additions & 0 deletions crates/pet-python-utils/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use lazy_static::lazy_static;
use log::trace;
use regex::Regex;
use std::ffi::OsStr;
use std::{
fs,
path::{Path, PathBuf},
Expand Down Expand Up @@ -159,6 +160,22 @@ pub fn should_search_for_environments_in_path<P: AsRef<Path>>(path: &P) -> bool
true
}

#[cfg(target_os = "windows")]
pub fn new_silent_command(program: impl AsRef<OsStr>) -> std::process::Command {
use std::os::windows::process::CommandExt;

const CREATE_NO_WINDOW: u32 = 0x08000000;

let mut command = std::process::Command::new(program);
command.creation_flags(CREATE_NO_WINDOW);
command
}

#[cfg(not(target_os = "windows"))]
pub fn new_silent_command(program: impl AsRef<OsStr>) -> std::process::Command {
std::process::Command::new(program)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading