diff --git a/inc/python b/inc/python index 0348cb389f..4a107ac8ec 100644 --- a/inc/python +++ b/inc/python @@ -31,6 +31,13 @@ function get_pip_command { # Get the path to the direcotry where python executables are installed. # 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 echo "/usr/bin" else @@ -39,8 +46,8 @@ function get_python_exec_prefix { } # Wrapper for ``pip install`` to set cache and proxy environment variables -# Uses globals ``INSTALL_TESTONLY_PACKAGES``, ``OFFLINE``, ``TRACK_DEPENDS``, -# ``*_proxy`` +# Uses globals ``INSTALL_TESTONLY_PACKAGES``, ``OFFLINE``, ``PIP_VIRTUAL_ENV``, +# ``TRACK_DEPENDS``, ``*_proxy`` # pip_install package [package ...] function pip_install { local xtrace=$(set +o | grep xtrace) @@ -62,8 +69,13 @@ function pip_install { local cmd_pip=$DEST/.venv/bin/pip local sudo_pip="env" else - local cmd_pip=$(get_pip_command) - local sudo_pip="sudo -H" + if [[ -n ${PIP_VIRTUAL_ENV:=} && -d ${PIP_VIRTUAL_ENV} ]]; then + 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 local pip_version=$(python -c "import pip; \ @@ -93,6 +105,7 @@ function pip_install { -r $test_req fi fi + $xtrace } # should we use this library from their git repo, or should we let it