Browse Source

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
changes/47/636447/2
Chris Hoge 4 months ago
parent
commit
ae6db7a387
1 changed files with 22 additions and 6 deletions
  1. 22
    6
      scripts/setup_pip.sh

+ 22
- 6
scripts/setup_pip.sh View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 set -ex
4 4
 
5
+
5 6
 if [[ "${PYTHON3}" == "no" ]]; then
6 7
     TMP_VIRTUALENV="virtualenv"
7 8
 else
@@ -13,12 +14,27 @@ fi
13 14
 if (( $(${TMP_VIRTUALENV} --version | cut -d. -f1) >= 14 )); then
14 15
     SETUPTOOLS="--no-setuptools"
15 16
 fi
16
-${TMP_VIRTUALENV} --extra-search-dir=/tmp/wheels ${SETUPTOOLS} /tmp/venv
17
-source /tmp/venv/bin/activate
18 17
 
19
-# TODO: Remove virtualenv version pinning once a suitable fix is found
20
-# to this issue:
21
-# http://lists.openstack.org/pipermail/openstack-discuss/2019-February/002592.html
22
-pip install --upgrade ${PIP_ARGS} virtualenv==16.3.0
18
+# virtualenv 16.4.0 fixed symlink handling. The interaction of the new
19
+# corrected behavior with legacy bugs in packaged virtualenv releases in
20
+# distributions means we need to hold on to the pip bootstrap installation
21
+# chain to preserve symlinks. As distributions upgrade their default
22
+# installations we may not need this workaround in the future
23
+PIPBOOTSTRAP=/var/lib/pipbootstrap
24
+
25
+# Create the boostrap environment so we can get pip from virtualenv
26
+${TMP_VIRTUALENV} --extra-search-dir=/tmp/wheels ${SETUPTOOLS} ${PIPBOOTSTRAP}
27
+source ${PIPBOOTSTRAP}/bin/activate
28
+
29
+# Upgrade to the latest version of virtualenv
30
+pip install --upgrade ${PIP_ARGS} virtualenv
31
+
32
+# Forget the cached locations of python binaries
23 33
 hash -r
34
+
35
+# Create the virtualenv with the updated toolchain for openstack service
24 36
 virtualenv --extra-search-dir=/tmp/wheels /var/lib/openstack
37
+
38
+# Deactivate the old bootstrap virtualenv and switch to the new one
39
+deactivate
40
+source /var/lib/openstack/bin/activate

Loading…
Cancel
Save