windows: Set CREATE_NO_WINDOW for commands (#18447)

- Closes: #18371

Release Notes:

- N/A
This commit is contained in:
张小白 2024-11-21 08:52:38 +08:00 committed by GitHub
parent 49ed932c1f
commit 95ace03706
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 122 additions and 174 deletions

View file

@ -16,7 +16,6 @@ pub use remote_kernels::*;
use anyhow::Result;
use runtimelib::{ExecutionState, JupyterKernelspec, JupyterMessage, KernelInfoReply};
use smol::process::Command;
use ui::SharedString;
pub type JupyterMessageChannel = stream::SelectAll<Receiver<JupyterMessage>>;
@ -85,7 +84,7 @@ pub fn python_env_kernel_specifications(
let python_path = toolchain.path.to_string();
// Check if ipykernel is installed
let ipykernel_check = Command::new(&python_path)
let ipykernel_check = util::command::new_smol_command(&python_path)
.args(&["-c", "import ipykernel"])
.output()
.await;

View file

@ -48,7 +48,7 @@ impl LocalKernelSpecification {
self.name
);
let mut cmd = Command::new(&argv[0]);
let mut cmd = util::command::new_smol_command(&argv[0]);
for arg in &argv[1..] {
if arg == "{connection_file}" {
@ -62,12 +62,6 @@ impl LocalKernelSpecification {
cmd.envs(env);
}
#[cfg(windows)]
{
use smol::process::windows::CommandExt;
cmd.creation_flags(windows::Win32::System::Threading::CREATE_NO_WINDOW.0);
}
Ok(cmd)
}
}
@ -350,17 +344,11 @@ pub async fn local_kernel_specifications(fs: Arc<dyn Fs>) -> Result<Vec<LocalKer
}
// Search for kernels inside the base python environment
let mut command = Command::new("python");
command.arg("-c");
command.arg("import sys; print(sys.prefix)");
#[cfg(windows)]
{
use smol::process::windows::CommandExt;
command.creation_flags(windows::Win32::System::Threading::CREATE_NO_WINDOW.0);
}
let command = command.output().await;
let command = util::command::new_smol_command("python")
.arg("-c")
.arg("import sys; print(sys.prefix)")
.output()
.await;
if let Ok(command) = command {
if command.status.success() {