Skip to content

Commit 5f7bdc8

Browse files
agl29ranade1
authored andcommitted
[multi-python] Improve the helper function
1 parent a1b7478 commit 5f7bdc8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/scripts/python/python_helper.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
set -ex
2020

2121
# Find the latest Python binary in build/env/bin
22-
LATEST_PYTHON=$(find "$HUE_HOME_DIR/build/env/bin" -name "python3*" -exec basename {} \; | sort -V | tail -n 1)
22+
LATEST_PYTHON=$([ -d "$HUE_HOME_DIR/build/env/bin" ] && find "$HUE_HOME_DIR/build/env/bin" -name "python3*" -exec basename {} \; | sort -V | tail -n 1 || echo "")
2323

2424
# Extract version from the latest python binary (e.g., python3.11 → 3.11)
25-
LATEST_PYTHON_VERSION=$(echo "$LATEST_PYTHON" | grep -oP '\d+\.\d+')
25+
LATEST_PYTHON_VERSION=$(echo "$LATEST_PYTHON" | grep -oP '\d+\.\d+' || echo "")
2626

2727
# Find all supported python versions from build/venvs and include latest version
2828
readarray -t SUPPORTED_VERSIONS < <(
2929
(
30-
find "$HUE_HOME_DIR/build/venvs" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | grep -oP '\d+\.\d+';
30+
[ -d "$HUE_HOME_DIR/build/venvs" ] && find "$HUE_HOME_DIR/build/venvs" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | grep -oP '\d+\.\d+'
3131
echo "$LATEST_PYTHON_VERSION"
3232
) | sort -Vr | uniq
3333
)

0 commit comments

Comments
 (0)