From 8fb40c66a441f67e162cd63fd35ec256ad0dee30 Mon Sep 17 00:00:00 2001 From: Discord9 Date: Wed, 6 Dec 2023 16:27:33 +0800 Subject: [PATCH] feat: opt path --- scripts/{greptime.sh => run-pyo3-greptime.sh} | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) rename scripts/{greptime.sh => run-pyo3-greptime.sh} (74%) diff --git a/scripts/greptime.sh b/scripts/run-pyo3-greptime.sh similarity index 74% rename from scripts/greptime.sh rename to scripts/run-pyo3-greptime.sh index 56d84928ed..8b2a5b35d2 100755 --- a/scripts/greptime.sh +++ b/scripts/run-pyo3-greptime.sh @@ -41,12 +41,44 @@ setup_conda_env() { conda activate "GreptimeTmpPyO3Env$req_py_version" } +get_optional_args(){ + # if not set by --path path-of-greptime-executable + # default to search local folder for greptime executable + ARGS=$(getopt -o "p:" -l "path:" -- "$@") + + # assign ARGS to positional parameters $1, $2, etc... + eval set -- "$ARGS" + unset ARGS + # default path to executable + exec_path="./greptime" + # parse for path + while true; do + case "$1" in + -p) + shift + exec_path="$1" + shift + ;; + --) + shift + break + ;; + *) + break + ;; + esac + done + export GREPTIME_EXEC_PATH=$exec_path + export REST_OF_ARGS=$@ +} + # Set library path and pass all arguments to greptime to run it execute_greptime() { + get_optional_args $@ if [[ "$OS_TYPE" == "Darwin" ]]; then - DYLD_LIBRARY_PATH="${CONDA_PREFIX:-$PREFIX}/lib:${LD_LIBRARY_PATH:-}" ./greptime "$@" + DYLD_LIBRARY_PATH="${CONDA_PREFIX:-$PREFIX}/lib:${LD_LIBRARY_PATH:-}" $GREPTIME_EXEC_PATH "$REST_OF_ARGS" elif [[ "$OS_TYPE" == "Linux" ]]; then - LD_LIBRARY_PATH="${CONDA_PREFIX:-$PREFIX}/lib:${LD_LIBRARY_PATH:-}" ./greptime "$@" + LD_LIBRARY_PATH="${CONDA_PREFIX:-$PREFIX}/lib:${LD_LIBRARY_PATH:-}" $GREPTIME_EXEC_PATH "$REST_OF_ARGS" fi }