@@ -187,7 +187,7 @@ setup_web_python() {
187187
188188 clone_repository " $REPO " " $TARGET_DIR " " "
189189
190- # detect_setup_python_env
190+ setup_python_venv " $TARGET_DIR "
191191
192192 pip3 install --only-binary grpcio -r requirements.txt >> " $NOW_RUN_LOG_FILE " 2>&1
193193 pip3 uninstall -y pytest-html pytest-rerunfailures >> " $NOW_RUN_LOG_FILE " 2>&1
@@ -240,7 +240,7 @@ setup_app_python() {
240240
241241 clone_repository " $REPO " " $TARGET_DIR "
242242
243- # detect_setup_python_env
243+ setup_python_venv " $TARGET_DIR "
244244
245245 # Install dependencies
246246 pip install --only-binary grpcio -r requirements.txt >> " $NOW_RUN_LOG_FILE " 2>&1
@@ -471,41 +471,25 @@ print_tests_running_log_section() {
471471}
472472
473473
474- detect_setup_python_env () {
474+ setup_python_venv () {
475+ local virtual_env_dir=" $1 /.venv"
476+
475477 log_info " Detecting latest Python environment"
476-
477- latest_python=$(
478- { ls -1 /usr/local/bin/python3.[0-9]* /usr/bin/python3.[0-9]* 2> /dev/null || true ; } \
479- | grep -E ' python3\.[0-9]+$' \
480- | sort -V \
481- | tail -n 1
482- )
483-
484- if [[ -z " $latest_python " ]]; then
485- log_warn " No specific Python3.x version found. Falling back to system python3."
486- latest_python=$( command -v python3)
487- fi
488-
489- if [[ -z " $latest_python " ]]; then
490- log_error " Python3 not found on this system."
491- exit 1
492- fi
493-
494- echo " 🐍 Switching to: $latest_python "
495- log_info " Using Python interpreter: $latest_python "
496-
497- " $latest_python " -m venv .venv || {
478+ local latest_python=" python3"
479+ log_msg_to " Creating virtual environment at $virtual_env_dir " " $NOW_RUN_LOG_FILE "
480+ log_info " Creating virtual environment at $virtual_env_dir "
481+ " $latest_python " -m venv " $virtual_env_dir " || {
498482 log_error " Failed to create virtual environment."
499483 exit 1
500484 }
501485
502486 # Activate virtual environment (handle Windows/Unix paths)
503- if [ -f " .venv /Scripts/activate" ]; then
487+ if [ -f " $virtual_env_dir /Scripts/activate" ]; then
504488 # shellcheck source=/dev/null
505- source .venv /Scripts/activate
489+ source " $virtual_env_dir " /Scripts/activate
506490 else
507491 # shellcheck source=/dev/null
508- source .venv /bin/activate
492+ source " $virtual_env_dir " /bin/activate
509493 fi
510494 log_success " Virtual environment created and activated."
511495}
0 commit comments