lf-pyver() fails to include the currently selected version in the output
of 'pyenv versions', which makes the version change every time the local
version is set by pyenv with the version from lf-pyver().
Fix the command to extract the list of Python versions to include all
the numeric versions in the list.
Issue-ID: RELENG-4403
Change-Id: I8eb1a1842a9ccd7514f096ec6989559a5526c3b6
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
local py_version_xy="${1:-python3}"
local py_version_xyz=""
local py_version_xy="${1:-python3}"
local py_version_xyz=""
- pyenv versions | sed 's/[[:alpha:]|(|)|/||*|[:space:]]//g'| tr -d ' ' \
+ pyenv versions | sed 's/^[ *]* //' | awk '{ print $1 }' | grep -E '^[0-9.]*[0-9]$' \
> "/tmp/.pyenv_versions"
if [[ ! -s "/tmp/.pyenv_versions" ]]; then
lf-echo-stderr "${FUNCNAME[0]}(): ERROR: pyenv not available"
> "/tmp/.pyenv_versions"
if [[ ! -s "/tmp/.pyenv_versions" ]]; then
lf-echo-stderr "${FUNCNAME[0]}(): ERROR: pyenv not available"
# strip out any prefix for (ex: 'python3.8' or 'v3.8') and match regex
# to the output return by pyenv
# strip out any prefix for (ex: 'python3.8' or 'v3.8') and match regex
# to the output return by pyenv
- py_version_xyz=$(grep "^${py_version_xy//[a-zA-Z]/}\(\..*\)\?\.[0-9]\+$" \
- "/tmp/.pyenv_versions" | sort -V | tail -n 1;)
- if [[ ! -n ${py_version_xyz} ]]; then
+ py_version_xyz=$(grep "^${py_version_xy//[a-zA-Z]/}" "/tmp/.pyenv_versions" |
+ sort -V | tail -n 1;)
+ if [[ -z ${py_version_xyz} ]]; then
lf-echo-stderr "${FUNCNAME[0]}(): ERROR: Not installed on host: ${py_version_xy}"
return 1
fi
lf-echo-stderr "${FUNCNAME[0]}(): ERROR: Not installed on host: ${py_version_xy}"
return 1
fi
--- /dev/null
+---
+fixes:
+ - |
+ lf-pyver() fails to include the currently selected version in the output
+ of 'pyenv versions', which makes the version change every time the local
+ version is set by pyenv with the version from lf-pyver().
+
+ Fix the command to extract the list of Python versions to include all
+ the numeric versions in the list.