From ae6db7a387f8a2a779c5e9c33830d1f8d8af7971 Mon Sep 17 00:00:00 2001 From: Chris Hoge Date: Tue, 12 Feb 2019 21:53:34 +0000 Subject: [PATCH] Fix broken symlinks from virtualenv 16.4.0 update The virtualenv 16.4.0 updates fixes the handling of creating symlinks of libraries to existing installations. Previously, virtualenv would copy existing libraries into the virtualenv making nested environments possible without retaining the "parent" virtualenv. Now virtualenv builds a symlink chain, which means we need to preserve the bootstrap virtualenv that gives us an up-to-date installation of pip and virtualenv. As distributions update their default virtualenv installations, we might be able to use the --always-copy flag to stop using symlinks and just copy dependencies over directly. However, the virtualenv that ships with CentOS has a bug that causes the use of that flag to fail, meaning as of right now we can't use it to boostrap pip. This patch moves the boostrap virtualenv from /tmp/venv, where it is deleted in the build process, to /var/lib/pipboostrap, where the symlink chain from /var/lib/openstack -> /var/lib/pipbootstrap -> /usr/lib will be remain unbroken. Change-Id: I99124c2cfeb6ba7468a034ab510071eb67d98d66 --- scripts/setup_pip.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/scripts/setup_pip.sh b/scripts/setup_pip.sh index 292d748..6edc367 100755 --- a/scripts/setup_pip.sh +++ b/scripts/setup_pip.sh @@ -2,6 +2,7 @@ set -ex + if [[ "${PYTHON3}" == "no" ]]; then TMP_VIRTUALENV="virtualenv" else @@ -13,12 +14,27 @@ fi if (( $(${TMP_VIRTUALENV} --version | cut -d. -f1) >= 14 )); then SETUPTOOLS="--no-setuptools" fi -${TMP_VIRTUALENV} --extra-search-dir=/tmp/wheels ${SETUPTOOLS} /tmp/venv -source /tmp/venv/bin/activate -# TODO: Remove virtualenv version pinning once a suitable fix is found -# to this issue: -# http://lists.openstack.org/pipermail/openstack-discuss/2019-February/002592.html -pip install --upgrade ${PIP_ARGS} virtualenv==16.3.0 +# virtualenv 16.4.0 fixed symlink handling. The interaction of the new +# corrected behavior with legacy bugs in packaged virtualenv releases in +# distributions means we need to hold on to the pip bootstrap installation +# chain to preserve symlinks. As distributions upgrade their default +# installations we may not need this workaround in the future +PIPBOOTSTRAP=/var/lib/pipbootstrap + +# Create the boostrap environment so we can get pip from virtualenv +${TMP_VIRTUALENV} --extra-search-dir=/tmp/wheels ${SETUPTOOLS} ${PIPBOOTSTRAP} +source ${PIPBOOTSTRAP}/bin/activate + +# Upgrade to the latest version of virtualenv +pip install --upgrade ${PIP_ARGS} virtualenv + +# Forget the cached locations of python binaries hash -r + +# Create the virtualenv with the updated toolchain for openstack service virtualenv --extra-search-dir=/tmp/wheels /var/lib/openstack + +# Deactivate the old bootstrap virtualenv and switch to the new one +deactivate +source /var/lib/openstack/bin/activate