From d2cc8ccb11558f1dbdb27a2351e34155c3a24ccf Mon Sep 17 00:00:00 2001 From: MarcusNyne <69087098+MarcusNyne@users.noreply.github.com> Date: Thu, 9 May 2024 17:16:53 -0400 Subject: [PATCH] When creating a virtual environment, upgrade pip Pip will be upgraded upon immediately creating the virtual environment. If the pip upgrade fails, this should not cause the script to fail (treat as a warning). After the environment is created, it will not attempt further updates to pip. --- webui.bat | 7 ++++++- webui.sh | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/webui.bat b/webui.bat index e2c9079d2..a8d479b05 100644 --- a/webui.bat +++ b/webui.bat @@ -37,10 +37,15 @@ if %ERRORLEVEL% == 0 goto :activate_venv for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i" echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME% %PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt -if %ERRORLEVEL% == 0 goto :activate_venv +if %ERRORLEVEL% == 0 goto :upgrade_pip echo Unable to create venv in directory "%VENV_DIR%" goto :show_stdout_stderr +:upgrade_pip +"%VENV_DIR%\Scripts\Python.exe" -m pip install --upgrade pip +if %ERRORLEVEL% == 0 goto :activate_venv +echo Warning: Failed to upgrade PIP version + :activate_venv set PYTHON="%VENV_DIR%\Scripts\Python.exe" echo venv %PYTHON% diff --git a/webui.sh b/webui.sh index c7c4bee98..7acea902c 100755 --- a/webui.sh +++ b/webui.sh @@ -210,6 +210,7 @@ then if [[ ! -d "${venv_dir}" ]] then "${python_cmd}" -m venv "${venv_dir}" + "${venv_dir}"/bin/python -m pip install --upgrade pip first_launch=1 fi # shellcheck source=/dev/null