From e489cf13634fb8d5a475ba422abff083cd74828e Mon Sep 17 00:00:00 2001 From: Xavier Tao Date: Thu, 5 Dec 2024 17:17:12 +0100 Subject: [PATCH 1/2] Fix an error with macos that is choosing the wrong python when running dora --- libraries/core/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/core/src/lib.rs b/libraries/core/src/lib.rs index e9ba36a35..003ee4704 100644 --- a/libraries/core/src/lib.rs +++ b/libraries/core/src/lib.rs @@ -31,15 +31,16 @@ pub fn adjust_shared_library_path(path: &Path) -> Result Result { - let python = if cfg!(windows) { + let python = if cfg!(windows) || cfg!(target_os = "macos") { which::which("python") .context("failed to find `python` or `python3`. Make sure that python is available.")? } else { which::which("python3") .context("failed to find `python` or `python3`. Make sure that python is available.")? }; + Ok(python) } From 31c0e76f8a8c8e00e16ebc4386ccc165c039d463 Mon Sep 17 00:00:00 2001 From: haixuantao Date: Thu, 5 Dec 2024 17:46:30 +0100 Subject: [PATCH 2/2] Force python run unbuffered print to avoid having to use flush=True within python --- binaries/daemon/src/spawn.rs | 4 ++++ libraries/core/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/binaries/daemon/src/spawn.rs b/binaries/daemon/src/spawn.rs index c5c564b2c..80c09d471 100644 --- a/binaries/daemon/src/spawn.rs +++ b/binaries/daemon/src/spawn.rs @@ -116,6 +116,8 @@ pub async fn spawn_node( let python = get_python_path().context("Could not get python path")?; tracing::info!("spawning: {:?} {}", &python, resolved_path.display()); let mut cmd = tokio::process::Command::new(&python); + // Force python to always flush stdout/stderr buffer + cmd.arg("-u"); cmd.arg(&resolved_path); cmd } @@ -221,6 +223,8 @@ pub async fn spawn_node( let python = get_python_path() .context("Could not find python path when spawning runtime node")?; let mut command = tokio::process::Command::new(python); + // Force python to always flush stdout/stderr buffer + command.arg("-u"); command.args([ "-c", format!("import dora; dora.start_runtime() # {}", node.id).as_str(), diff --git a/libraries/core/src/lib.rs b/libraries/core/src/lib.rs index 003ee4704..a003a002f 100644 --- a/libraries/core/src/lib.rs +++ b/libraries/core/src/lib.rs @@ -33,7 +33,7 @@ pub fn adjust_shared_library_path(path: &Path) -> Result Result { - let python = if cfg!(windows) || cfg!(target_os = "macos") { + let python = if cfg!(windows) || cfg!(target_os = "macos") { which::which("python") .context("failed to find `python` or `python3`. Make sure that python is available.")? } else {