Merge "Teach pip_install() about virtual envs"

This commit is contained in:
Jenkins
2015-02-18 20:59:20 +00:00
committed by Gerrit Code Review

View File

@@ -31,6 +31,13 @@ function get_pip_command {
# Get the path to the direcotry where python executables are installed. # Get the path to the direcotry where python executables are installed.
# get_python_exec_prefix # get_python_exec_prefix
function get_python_exec_prefix { function get_python_exec_prefix {
local xtrace=$(set +o | grep xtrace)
set +o xtrace
if [[ -z "$os_PACKAGE" ]]; then
GetOSVersion
fi
$xtrace
if is_fedora || is_suse; then if is_fedora || is_suse; then
echo "/usr/bin" echo "/usr/bin"
else else
@@ -39,8 +46,8 @@ function get_python_exec_prefix {
} }
# Wrapper for ``pip install`` to set cache and proxy environment variables # Wrapper for ``pip install`` to set cache and proxy environment variables
# Uses globals ``INSTALL_TESTONLY_PACKAGES``, ``OFFLINE``, ``TRACK_DEPENDS``, # Uses globals ``INSTALL_TESTONLY_PACKAGES``, ``OFFLINE``, ``PIP_VIRTUAL_ENV``,
# ``*_proxy`` # ``TRACK_DEPENDS``, ``*_proxy``
# pip_install package [package ...] # pip_install package [package ...]
function pip_install { function pip_install {
local xtrace=$(set +o | grep xtrace) local xtrace=$(set +o | grep xtrace)
@@ -62,8 +69,13 @@ function pip_install {
local cmd_pip=$DEST/.venv/bin/pip local cmd_pip=$DEST/.venv/bin/pip
local sudo_pip="env" local sudo_pip="env"
else else
local cmd_pip=$(get_pip_command) if [[ -n ${PIP_VIRTUAL_ENV:=} && -d ${PIP_VIRTUAL_ENV} ]]; then
local sudo_pip="sudo -H" local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
local sudo_pip="env"
else
local cmd_pip=$(get_pip_command)
local sudo_pip="sudo -H"
fi
fi fi
local pip_version=$(python -c "import pip; \ local pip_version=$(python -c "import pip; \
@@ -93,6 +105,7 @@ function pip_install {
-r $test_req -r $test_req
fi fi
fi fi
$xtrace
} }
# get version of a package from global requirements file # get version of a package from global requirements file