Skip to content

Commit d46d220

Browse files
committed
organize code
1 parent d4e34dd commit d46d220

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

environment/src/lib.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ pub fn install_env(env: &str) {
22
match env {
33
"python" => {
44
println!("\x1b[32m[xtask]\x1b[0m Checking if Python is already installed...");
5+
println!();
6+
57
// Check if python or python3 is installed
68
let check_installed = if cfg!(target_os = "windows") {
79
std::process::Command::new("python")
810
.arg("--version")
11+
.stdout(std::process::Stdio::null())
912
.status()
1013
.map(|s| s.success())
1114
.unwrap_or(false)
1215
} else {
1316
std::process::Command::new("python3")
1417
.arg("--version")
18+
.stdout(std::process::Stdio::null())
1519
.status()
1620
.map(|s| s.success())
1721
.unwrap_or(false)
@@ -40,6 +44,7 @@ pub fn install_env(env: &str) {
4044
std::process::Command::new("sh")
4145
.arg("-c")
4246
.arg(format!("command -v {}", cmd))
47+
.stdout(std::process::Stdio::null())
4348
.status()
4449
.map(|s| s.success())
4550
.unwrap_or(false)
@@ -95,9 +100,12 @@ pub fn install_env(env: &str) {
95100
}
96101
"xmake" => {
97102
println!("\x1b[32m[xtask]\x1b[0m Checking if xmake is already installed...");
103+
println!();
104+
98105
// Check if xmake is installed
99106
let check_installed = std::process::Command::new("xmake")
100107
.arg("--version")
108+
.stdout(std::process::Stdio::null())
101109
.status()
102110
.map(|s| s.success())
103111
.unwrap_or(false);
@@ -140,9 +148,12 @@ pub fn install_env(env: &str) {
140148
}
141149
"cuda" => {
142150
println!("\x1b[32m[xtask]\x1b[0m Checking if CUDA Toolkit is already installed...");
151+
println!();
152+
143153
// Check if cuda toolkit is installed
144154
let check_installed = std::process::Command::new("nvcc")
145155
.arg("--version")
156+
.stdout(std::process::Stdio::null())
146157
.status()
147158
.map(|s| s.success())
148159
.unwrap_or(false);
@@ -156,6 +167,7 @@ pub fn install_env(env: &str) {
156167

157168
// nvidia-smi, get the highest CUDA version supported by the driver
158169
let has_nvidia_smi = std::process::Command::new("nvidia-smi")
170+
.stdout(std::process::Stdio::null())
159171
.status()
160172
.map(|s| s.success())
161173
.unwrap_or(false);
@@ -170,7 +182,7 @@ pub fn install_env(env: &str) {
170182
println!("\x1b[32m[xtask]\x1b[0m Detected by nvidia-smi: {line}");
171183
}
172184
if let Some(idx) = line.find("CUDA Version:") {
173-
// 提取 CUDA 版本号
185+
// extract the CUDA version number
174186
let version_str = line[idx + "CUDA Version:".len()..]
175187
.split_whitespace()
176188
.next()
@@ -192,8 +204,7 @@ pub fn install_env(env: &str) {
192204
);
193205
}
194206

195-
// println!("\x1b[32m[xtask]\x1b[0m CUDA Toolkit not detected. Installing CUDA Toolkit...");
196-
207+
println!();
197208
println!(
198209
"\x1b[32m[xtask]\x1b[0m Please visit https://developer.nvidia.com/cuda-toolkit-archive to select and download the appropriate CUDA version for your driver."
199210
);

0 commit comments

Comments
 (0)