From: Aric Gardner Date: Mon, 23 Sep 2019 17:27:05 +0000 (-0400) Subject: Move python version to python3 X-Git-Tag: v0.44.0~1 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=eeeb5656c1c3aec9ad08918b916263c81ec626b9;p=releng%2Fglobal-jjb.git Move python version to python3 Remove pin workarounds for python2 install tox via python3 pip so that the version of tox is run from /home/jenkins/.local/lib/python3.6/site-packages/tox/__init__.py fix release-job to use venv Signed-off-by: Aric Gardner Change-Id: I4b2d778f3fd81565c5dd009d50c969696faba0d2 Signed-off-by: Tim Johnson --- diff --git a/jjb/lf-python-jobs.yaml b/jjb/lf-python-jobs.yaml index 451eb635..7eba8edb 100644 --- a/jjb/lf-python-jobs.yaml +++ b/jjb/lf-python-jobs.yaml @@ -230,7 +230,7 @@ mvn-settings: "{mvn-settings}" mvn-version: mvn35 pre-build-script: "# pre-build script goes here" - python-version: python2 + python-version: python3 sonar-mvn-goal: "sonar:sonar" stream: master submodule-recursive: true @@ -395,7 +395,7 @@ github-url: "https://github.com" parallel: true pre-build-script: "# pre-build script goes here" - python-version: python2 + python-version: python3 stream: master submodule-recursive: true submodule-timeout: 10 diff --git a/shell/python-tools-install.sh b/shell/python-tools-install.sh index be6d1810..1f5beec0 100644 --- a/shell/python-tools-install.sh +++ b/shell/python-tools-install.sh @@ -19,7 +19,7 @@ pip_list_pre=/tmp/pip-list-pre.txt pip_list_post=/tmp/pip-list-post.txt pip_list_diffs=/tmp/pip-list-diffs.txt if [[ -f $pip_list_pre ]]; then - pip list > $pip_list_post + python3 -m pip list > $pip_list_post echo "Compare pip packages before/after..." if diff --suppress-common-lines $pip_list_pre $pip_list_post \ | tee $pip_list_diffs; then @@ -33,7 +33,7 @@ if [[ -f $pip_list_pre ]]; then # log-deploy.sh script is 'appended' to this file and it would not # be executed. else - pip list > "$pip_list_pre" + python3 -m pip list > "$pip_list_pre" # These 'pip installs' only need to be executed during pre-build requirements_file=$(mktemp /tmp/requirements-XXXX.txt) @@ -44,20 +44,18 @@ else echo "Generating Requirements File" cat << 'EOF' > "$requirements_file" -lftools[openstack]~=0.26.2 -python-cinderclient~=4.3.0 -python-heatclient~=1.16.1 -python-openstackclient~=3.16.0 -dogpile.cache~=0.6.8 # Version 0.7.[01] seems to break openstackclient -more-itertools~=5.0.0 -niet~=1.4.2 # Extract values from yaml -tox>=3.7.0. # Tox 3.7 or greater is necessary for parallel mode support -yq~=2.7.2 +lftools[openstack] +python-heatclient +python-openstackclient +niet~=1.4.2 +tox>=3.7.0 # Tox 3.7 or greater is necessary for parallel mode support +yq EOF # Use `python -m pip` to ensure we are using the latest version of pip - python -m pip install --user --quiet --upgrade pip - python -m pip install --user --quiet --upgrade setuptools - python -m pip install --user --quiet --upgrade -r "$requirements_file" + python3 -m venv ~/.local + python3 -m pip install --user --quiet --upgrade pip + python3 -m pip install --user --quiet --upgrade setuptools + python3 -m pip install --user --quiet --upgrade -r "$requirements_file" rm -rf "$requirements_file" fi diff --git a/shell/release-job.sh b/shell/release-job.sh index c27a87f8..b764ac19 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -11,25 +11,12 @@ echo "---> release-job.sh" set -eu -o pipefail -#Python bits. Remove when centos 7.7 builder is avaliable. -if [ -d "/opt/pyenv" ]; then - echo "INFO: Setting up pyenv" - export PYENV_ROOT="/opt/pyenv" - export PATH="$PYENV_ROOT/bin:$PATH" -fi -PYTHONPATH=$(pwd) -export PYTHONPATH - -latest_version=$(pyenv versions \ - | sed s,*,,g \ - | awk '/[0-9]+/{ print $1 }' \ - | sort --version-sort \ - | awk '/./{line=$0} END{print line}') - -pyenv local "$latest_version" - -export PYENV_VERSION="$latest_version" -pip install --user lftools[nexus] jsonschema niet yq +set +u +python3 -m venv /tmp/v/venv/ +# shellcheck disable=SC1091 +source /tmp/v/venv/bin/activate +set -u +python -m pip install lftools[nexus] jsonschema niet yq #Functions. diff --git a/shell/tox-run.sh b/shell/tox-run.sh index c1598917..8be8459f 100644 --- a/shell/tox-run.sh +++ b/shell/tox-run.sh @@ -10,27 +10,19 @@ ############################################################################## echo "---> tox-run.sh" -# Ensure we fail the job if any steps fail. -# DO NOT set -u as virtualenv's activate script has unbound variables -set -e -o pipefail - ARCHIVE_TOX_DIR="$WORKSPACE/archives/tox" mkdir -p "$ARCHIVE_TOX_DIR" -cd "$WORKSPACE/$TOX_DIR" +cd "$WORKSPACE/$TOX_DIR" || exit 1 if [ -d "/opt/pyenv" ]; then echo "---> Setting up pyenv" export PYENV_ROOT="/opt/pyenv" export PATH="$PYENV_ROOT/bin:$PATH" + PYTHONPATH="$(pwd)" + export PYTHONPATH + export TOX_TESTENV_PASSENV=PYTHONPATH fi -# Set and pass in PYTHONPATH to circumvent installation bug in tox>=3.2.0 -PYTHONPATH=$(pwd) -export PYTHONPATH -export TOX_TESTENV_PASSENV=PYTHONPATH - -set +e # Allow detox to fail so that we can collect the logs in the next step - PARALLEL="${PARALLEL:-true}" if [ "${PARALLEL}" = true ]; then if [ -n "$TOX_ENVS" ]; then @@ -56,7 +48,6 @@ for i in .tox/*/log; do tox_env=$(echo "$i" | awk -F'/' '{print $2}') cp -r "$i" "$ARCHIVE_TOX_DIR/$tox_env" done -set -e # Logs collected so re-enable echo "Completed tox runs."