Allow overridable node binary paths

This commit is contained in:
andrussal 2025-12-02 08:42:33 +01:00
parent e0e7d32159
commit 0d7f3332fa
2 changed files with 28 additions and 0 deletions

View File

@ -1,5 +1,6 @@
use std::{ use std::{
collections::HashSet, collections::HashSet,
env,
path::PathBuf, path::PathBuf,
process::{Child, Command, Stdio}, process::{Child, Command, Stdio},
time::Duration, time::Duration,
@ -30,11 +31,24 @@ use crate::{IS_DEBUG_TRACING, adjust_timeout, nodes::LOGS_PREFIX};
const BIN_PATH: &str = "target/debug/nomos-executor"; const BIN_PATH: &str = "target/debug/nomos-executor";
fn binary_path() -> PathBuf { fn binary_path() -> PathBuf {
if let Some(path) = env::var_os("NOMOS_EXECUTOR_BIN") {
return PathBuf::from(path);
}
if let Some(path) = which_on_path("nomos-executor") {
return path;
}
PathBuf::from(env!("CARGO_MANIFEST_DIR")) PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../") .join("../../")
.join(BIN_PATH) .join(BIN_PATH)
} }
fn which_on_path(bin: &str) -> Option<PathBuf> {
let path_env = env::var_os("PATH")?;
env::split_paths(&path_env)
.map(|p| p.join(bin))
.find(|candidate| candidate.is_file())
}
pub struct Executor { pub struct Executor {
tempdir: tempfile::TempDir, tempdir: tempfile::TempDir,
child: Child, child: Child,

View File

@ -1,5 +1,6 @@
use std::{ use std::{
collections::HashSet, collections::HashSet,
env,
path::PathBuf, path::PathBuf,
process::{Child, Command, Stdio}, process::{Child, Command, Stdio},
time::Duration, time::Duration,
@ -29,11 +30,24 @@ use crate::{IS_DEBUG_TRACING, adjust_timeout, nodes::LOGS_PREFIX};
const BIN_PATH: &str = "target/debug/nomos-node"; const BIN_PATH: &str = "target/debug/nomos-node";
fn binary_path() -> PathBuf { fn binary_path() -> PathBuf {
if let Some(path) = env::var_os("NOMOS_NODE_BIN") {
return PathBuf::from(path);
}
if let Some(path) = which_on_path("nomos-node") {
return path;
}
PathBuf::from(env!("CARGO_MANIFEST_DIR")) PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../") .join("../../")
.join(BIN_PATH) .join(BIN_PATH)
} }
fn which_on_path(bin: &str) -> Option<PathBuf> {
let path_env = env::var_os("PATH")?;
env::split_paths(&path_env)
.map(|p| p.join(bin))
.find(|candidate| candidate.is_file())
}
pub enum Pool { pub enum Pool {
Da, Da,
Mantle, Mantle,