Skip to content

Commit c4e312c

Browse files
authored
Merge pull request #715 from vishnoianil/pyenv-dir
Normalize python virtual environment directory path if it's not an ab…
2 parents 4e3535e + 66a5c17 commit c4e312c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

installers/podman/ilab-ui-native-installer.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ discover_taxonomy_path() {
250250
taxonomy_path=$(ilab config show 2>/dev/null | grep "taxonomy_path" | head -n 1 | cut -d ':' -f 2 | sed 's/^ *//;s/ *$//' | tr -d '\r\n')
251251
else
252252
# Always use discovered python virtual environment,
253-
venv_ilab="$DISCOVERED_PYENV_DIR/bin/ilab"
253+
venv_ilab_dir=$([ -z "$DISCOVERED_PYENV_DIR" ] && echo "$PYENV_DIR" || echo "$DISCOVERED_PYENV_DIR")
254+
venv_ilab="$venv_ilab_dir/bin/ilab"
254255
taxonomy_path=$($venv_ilab config show 2>/dev/null | grep "taxonomy_path" | head -n 1 | cut -d ':' -f 2 | sed 's/^ *//;s/ *$//' | tr -d '\r\n')
255256
fi
256257
else
@@ -286,6 +287,19 @@ normalize_taxonomy_path() {
286287
fi
287288
}
288289

290+
normalize_pyvenv_dir_path() {
291+
echo -e "normalize_pyvenv_dir_path called- $PYENV_DIR"
292+
293+
if [[ "$PYENV_DIR" != /* ]]; then
294+
if ! command -v realpath &>/dev/null; then
295+
PYENV_DIR=$(realpath "$PYENV_DIR" 2>/dev/null)
296+
else
297+
PYENV_DIR="$(cd "$(dirname "$PYENV_DIR")" && pwd)/$(basename "$PYENV_DIR")"
298+
fi
299+
echo -e "${blue} Python virtual environment path normalized to absolute path $PYENV_DIR${reset}\n"
300+
fi
301+
}
302+
289303
# Parse input arguments
290304
if [[ $# -lt 1 ]]; then
291305
usage
@@ -328,6 +342,7 @@ if [[ "$COMMAND" == "install" ]]; then
328342
;;
329343
--python-venv-dir)
330344
PYENV_DIR=$(echo "$2" | sed 's/^ *//;s/ *$//')
345+
normalize_pyvenv_dir_path
331346
shift 2
332347
;;
333348
--deploy)

0 commit comments

Comments
 (0)