Fix: Use pyenv for PyPI verify jobs 95/70795/1
authorAnil Belur <abelur@linuxfoundation.org>
Tue, 4 Oct 2022 01:15:08 +0000 (11:15 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Tue, 4 Oct 2022 01:24:37 +0000 (11:24 +1000)
PyPI verify jobs requires Python 3.x. The tox run picks up default version
of python instead of the version made available through pyenv.

To fix this Re-factor lf-activate-venv() to skip a return, while the venv is
re-used, so that the PATH can be set.

Update the tox install and run script to Call lf-avtivate-venv().

Issue-ID: https://jira.linuxfoundation.org/browse/RELENG-4468
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
Change-Id: Ibde3ba8beb5be75fa69c9ee6cf36a80768a8f368

jenkins-init-scripts/lf-env.sh
releasenotes/notes/refactor-tox-pyenv-f5b3aac7eec3725d.yaml [new file with mode: 0644]
shell/tox-install.sh
shell/tox-run.sh

index 91aa80c..f80dc79 100644 (file)
@@ -245,13 +245,13 @@ lf-activate-venv () {
         "$lf_venv/bin/pip" install --upgrade --quiet pip virtualenv || return 1
         if [[ -z $pkg_list ]]; then
             echo "${FUNCNAME[0]}(): WARNING: No packages to install"
-            return 0
+        else
+            echo "${FUNCNAME[0]}(): INFO: Installing: $pkg_list"
+            # $pkg_list is expected to be unquoted
+            # shellcheck disable=SC2086
+            "$lf_venv/bin/pip" install --upgrade --quiet --upgrade-strategy eager \
+                                    $pkg_list || return 1
         fi
-        echo "${FUNCNAME[0]}(): INFO: Installing: $pkg_list"
-        # $pkg_list is expected to be unquoted
-        # shellcheck disable=SC2086
-        "$lf_venv/bin/pip" install --upgrade --quiet --upgrade-strategy eager \
-                                $pkg_list || return 1
         ;;
     *)
         lf-echo-stderr "${FUNCNAME[0]}(): ERROR: No support for: $python"
diff --git a/releasenotes/notes/refactor-tox-pyenv-f5b3aac7eec3725d.yaml b/releasenotes/notes/refactor-tox-pyenv-f5b3aac7eec3725d.yaml
new file mode 100644 (file)
index 0000000..7d1304c
--- /dev/null
@@ -0,0 +1,11 @@
+---
+prelude: >
+    PyPI verify jobs requires Python 3.x. The tox run picks up default version
+    of python instead of the version made available through pyenv.
+issues:
+  - |
+    Re-factor lf-activate-venv() to skip a return, while the venv is
+    re-used, so that the PATH can be set.
+fixes:
+  - |
+    Update the tox install and run script to Call lf-avtivate-venv().
index 02db0c2..5e527b3 100644 (file)
@@ -14,7 +14,10 @@ echo "---> tox-install.sh"
 # Use -x to show value of $PYTHON in output
 set -eux -o pipefail
 
-python3 -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv
+# shellcheck disable=SC1090
+source ~/lf-env.sh
+
+lf-activate-venv --python python3.8 --venv-file /tmp/.toxenv tox tox-pyenv virtualenv
 
 # installs are silent, show version details in log
 $PYTHON --version
index 4321ea6..758759b 100644 (file)
@@ -21,6 +21,11 @@ ARCHIVE_DOC_DIR="$WORKSPACE/archives/docs"
 mkdir -p "$ARCHIVE_TOX_DIR"
 cd "$WORKSPACE/$TOX_DIR" || exit 1
 
+# shellcheck disable=SC1090
+source ~/lf-env.sh
+
+lf-activate-venv --python python3.8 --venv-file /tmp/.toxenv tox tox-pyenv virtualenv
+
 if [[ -d /opt/pyenv ]]; then
     echo "---> Setting up pyenv"
     export PYENV_ROOT="/opt/pyenv"