Browse files

Use unique build dir for pip installs

There is a bug in pip [1] where it will choose to install a package
from an existing build-dir if it exists over the version actually

Thus if a prior component has installed a later version of the
package, the unpacked code is already in /tmp/$USER-pip-build; it gets
re-installed and manifests in a confusing error along the lines of

 Downloading/unpacking requests>=1.1,<1.2.3
   (from -r /home/stack//python-cinderclient/requirements.txt (line 5))
   Running egg_info for package requests
   Requested requests>=1.1,<1.2.3 (from -r
   /home/stack/python-cinderclient/requirements.txt (line 5)),
    but installing version 1.2.3
  error: Installed distribution requests 1.2.3 conflicts with
    requirement requests>=1.1,<1.2.3

I believe pip 1.4 fixes this problem, but it should always be safe to
specify a unique build-directory for pip installs to avoid picking up
old versions.

We also add a cleanup_tmp function for clearing out anything that might leave around when un-stacking, and add a catch-all for
the pip-build dir.

[1] pypa/pip#709

Change-Id: I7ce919cddfd6d6175ae67bd864f82e256ebc7090
  • Loading branch information...
ianw committed Jul 16, 2013
1 parent 89b5884 commit 31dcd3e7ab60855d9664bd0aeb87b79eba94913f
Showing with 24 additions and 1 deletion.
  1. +22 −1 functions
  2. +2 −0
@@ -913,14 +913,35 @@ function pip_install {
# pip < 1.4 has a bug where it will use an already existing build
# directory unconditionally. Say an earlier component installs
# foo v1.1; pip will have built foo's source in
# /tmp/$USER-pip-build. Even if a later component specifies foo <
# 1.1, the existing extracted build will be used and cause
# confusing errors. By creating unique build directories we avoid
# this problem. See
local pip_build_tmp=$(mktemp --tmpdir -d pip-build.XXXXX)
HTTP_PROXY=$http_proxy \
HTTPS_PROXY=$https_proxy \
NO_PROXY=$no_proxy \
$CMD_PIP install --build=${pip_build_tmp} \
&& $SUDO_PIP rm -rf ${pip_build_tmp}
# Cleanup anything from /tmp on unstack
# clean_tmp
function cleanup_tmp {
local tmp_dir=${TMPDIR:-/tmp}
# see comments in pip_install
sudo rm -rf ${tmp_dir}/pip-build.*
# Service wrapper to restart services
# restart_service service-name
function restart_service() {
@@ -111,3 +111,5 @@ if is_service_enabled neutron; then

0 comments on commit 31dcd3e

Please sign in to comment.