From 2b42f73e3d198f7d21de3bba9253fdcd4cc0d76d Mon Sep 17 00:00:00 2001 From: kopyl Date: Tue, 18 Jul 2023 22:43:18 +0300 Subject: [PATCH 1/3] Make possible to install web ui without venv with --novenv flag When passing `--novenv` flag to webui.sh it can skip venv. Might be useful for installing in Docker since messing with venv in Docker might be a bit complicated. Example usage: `webui.sh --novenv` Hope this gets approved and pushed into future versions of Web UI --- webui.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/webui.sh b/webui.sh index 5c8d977c..9ec14168 100755 --- a/webui.sh +++ b/webui.sh @@ -4,6 +4,11 @@ # change the variables in webui-user.sh instead # ################################################# +usevenv=1 +if [[ $@ == *"--novenv"* ]]; then + usevenv=0 +fi + # If run from macOS, load defaults from webui-macos-env.sh if [[ "$OSTYPE" == "darwin"* ]]; then if [[ -f webui-macos-env.sh ]] @@ -45,7 +50,7 @@ then fi # python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv) -if [[ -z "${venv_dir}" ]] +if [[ -z "${venv_dir}" ]] && [[ $usevenv -eq 1 ]] then venv_dir="venv" fi @@ -158,7 +163,7 @@ do fi done -if ! "${python_cmd}" -c "import venv" &>/dev/null +if [[ $usevenv -eq 1 ]] && ! "${python_cmd}" -c "import venv" &>/dev/null then printf "\n%s\n" "${delimiter}" printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m" @@ -178,7 +183,7 @@ else cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } fi -if [[ -z "${VIRTUAL_ENV}" ]]; +if [[ $usevenv -eq 1 ]] && [[ -z "${VIRTUAL_ENV}" ]]; then printf "\n%s\n" "${delimiter}" printf "Create and activate python venv" @@ -201,7 +206,7 @@ then fi else printf "\n%s\n" "${delimiter}" - printf "python venv already activate: ${VIRTUAL_ENV}" + printf "python venv already activate or run without venv: ${VIRTUAL_ENV}" printf "\n%s\n" "${delimiter}" fi From 0c4ca5f43e5e74aa1e7f65b3b6c20a676e158328 Mon Sep 17 00:00:00 2001 From: kopyl Date: Wed, 19 Jul 2023 01:47:39 +0300 Subject: [PATCH 2/3] Replace argument with env variable --- webui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webui.sh b/webui.sh index 9ec14168..5b39244b 100755 --- a/webui.sh +++ b/webui.sh @@ -5,7 +5,7 @@ ################################################# usevenv=1 -if [[ $@ == *"--novenv"* ]]; then +if [[ $venv_dir == "-" ]]; then usevenv=0 fi From 6094310704f4b3853bfa5d05d9c1ace58b2deee7 Mon Sep 17 00:00:00 2001 From: kopyl Date: Wed, 19 Jul 2023 01:48:21 +0300 Subject: [PATCH 3/3] improve var naming --- webui.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webui.sh b/webui.sh index 5b39244b..ed4cb4c8 100755 --- a/webui.sh +++ b/webui.sh @@ -4,9 +4,9 @@ # change the variables in webui-user.sh instead # ################################################# -usevenv=1 +use_venv=1 if [[ $venv_dir == "-" ]]; then - usevenv=0 + use_venv=0 fi # If run from macOS, load defaults from webui-macos-env.sh @@ -50,7 +50,7 @@ then fi # python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv) -if [[ -z "${venv_dir}" ]] && [[ $usevenv -eq 1 ]] +if [[ -z "${venv_dir}" ]] && [[ $use_venv -eq 1 ]] then venv_dir="venv" fi @@ -163,7 +163,7 @@ do fi done -if [[ $usevenv -eq 1 ]] && ! "${python_cmd}" -c "import venv" &>/dev/null +if [[ $use_venv -eq 1 ]] && ! "${python_cmd}" -c "import venv" &>/dev/null then printf "\n%s\n" "${delimiter}" printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m" @@ -183,7 +183,7 @@ else cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } fi -if [[ $usevenv -eq 1 ]] && [[ -z "${VIRTUAL_ENV}" ]]; +if [[ $use_venv -eq 1 ]] && [[ -z "${VIRTUAL_ENV}" ]]; then printf "\n%s\n" "${delimiter}" printf "Create and activate python venv"