Skip to content

Commit 2cae88d

Browse files
committed
fix: find_python_executable Linux 호환 - python3/python 순차 탐색
1 parent e01dacc commit 2cae88d

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

rust-bridge/src/lib.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,28 @@ impl BridgeState {
5757
}
5858

5959
fn find_python_executable(&self) -> String {
60-
let embedded_path = format!("{}/python_dist/python.exe", self.work_dir);
61-
if std::path::Path::new(&embedded_path).exists() {
62-
return embedded_path;
60+
let candidates = [
61+
format!("{}/python_dist/python.exe", self.work_dir),
62+
format!("{}/python_dist/python3", self.work_dir),
63+
];
64+
for path in &candidates {
65+
if std::path::Path::new(path).exists() {
66+
return path.clone();
67+
}
68+
}
69+
70+
let system_candidates = ["python3", "python"];
71+
for cmd in &system_candidates {
72+
let check = Command::new("which").arg(cmd).output();
73+
if let Ok(output) = check {
74+
if output.status.success() {
75+
return cmd.to_string();
76+
}
77+
}
6378
}
64-
self.log_to_java("WARN", "[Rust] Embedded Python not found. Falling back to 'python'.");
65-
"python".to_string()
79+
80+
self.log_to_java("WARN", "[Rust] No Python executable found. Falling back to 'python3'.");
81+
"python3".to_string()
6682
}
6783

6884
fn spawn_python_daemon(&self) -> Result<PythonDaemon, String> {

0 commit comments

Comments
 (0)