]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Fixing creation of virtual environment in update-env.sh
authorFrank Brehm <frank@brehm-online.com>
Wed, 9 Feb 2022 08:31:02 +0000 (09:31 +0100)
committerFrank Brehm <frank@brehm-online.com>
Wed, 9 Feb 2022 08:31:02 +0000 (09:31 +0100)
requirements.txt
update-env.sh

index db5cbc87936a5d2d2b9807df17439621f2f3934c..1b1fd356084d5e191e0155491f6cd43965b296f0 100644 (file)
@@ -1,6 +1,5 @@
 fb_logging
 fb_tools
-ansible
 ldap3
 PyYAML
 tzlocal
index 3bc2b8b1746ad7c2e49ec85d06ea8523b5d6c82f..b70764829a1eb3452b07ca909aea73c01cbdb6dc 100755 (executable)
@@ -28,7 +28,6 @@ export VIRTUAL_ENV_DISABLE_PROMPT=y
 declare -a VALID_PY_VERSIONS=("3.9" "3.8" "3.7" "3.6" "3.5")
 PY_VERSION_FINAL=
 PYTHON=
-VENV_BIN='virtualenv'
 
 #-------------------------------------------------------------------
 detect_color() {
@@ -127,6 +126,22 @@ error() {
     fi
 }
 
+#------------------------------------------------------------------------------
+RM() {
+
+    local cmd="rm $*"
+    if [[ "${VERBOSE}" == "y" ]] ; then
+        cmd="rm --verbose $*"
+    fi
+    debug "Executing: ${cmd}"
+    if [[ "${VERBOSE}" != "y" ]] ; then
+        rm "$@"
+    else
+        rm --verbose "$@"
+    fi
+
+}
+
 #------------------------------------------------------------------------------
 description() {
     cat <<-EOF
@@ -278,26 +293,6 @@ get_options() {
         exit 5
     fi
 
-    info "Searching for valid virtualenv …"
-    VENV_BIN="virtualenv-${PY_VERSION_FINAL}"
-    debug "Testing '${VENV_BIN}' …"
-    if type -t "${VENV_BIN}" >/dev/null ; then
-        :
-    else
-        VENV_BIN="virtualenv"
-        debug "Testing '${VENV_BIN}' …"
-        if type -t "${VENV_BIN}" >/dev/null ; then
-            :
-        else
-            empty_line >&2
-            error "Did not found a usable virtualenv." >&2
-            error "Command '${RED}virtualenv${NORMAL}' not found, please install package '${YELLOW}python-virtualenv${NORMAL}' or appropriate."
-            empty_line >&2
-            exit 6
-        fi
-    fi
-    info "Found '${GREEN}${VENV_BIN}${NORMAL}'."
-
     if type -t msgfmt >/dev/null ; then
         :
     else
@@ -324,13 +319,20 @@ init_venv() {
 
     if [[ ! -f venv/bin/activate ]] ; then
 
-        empty_line
-        if [[ "${VENV_BIN}" == 'virtualenv' ]] ; then
-            virtualenv --python="${PYTHON}" venv
-        else
-            ${VENV_BIN} venv
+        if [[ -e 'venv' ]] ; then
+            if [[ -d 'venv' ]] ; then
+                info "Removing directory '${CYAN}venv${NORMAL}' ..."
+                RM -r 'venv'
+            else
+                error "Path '${RED}venv${NORMAL}' exists, but is not a directory."
+                exit 11
+            fi
         fi
 
+        empty_line
+        info "Creating virtual environment in '${CYAN}venv${NORMAL}' ..."
+        "${PYTHON}" -m venv venv
+
     fi
 
     # shellcheck disable=SC1091