File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 > {
You can’t perform that action at this time.
0 commit comments