From 29bf8523965b504624f9450f3dffe863994b4077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Fri, 24 Jan 2020 11:52:13 +0100 Subject: [PATCH] Do not try finding pip for python2 when not required [1] stopped installing pip for py2 when py3 is being used. This patch makes sure we check only for py3 pip then. Also removed some no-longer-relevant comment and made uninstall behave the same. Check for pip>=6 removed too. See also [2]. [1] 279a7589b03db69fd1b85d947cd0171dacef94ee [2] http://lists.openstack.org/pipermail/openstack-discuss/2020-January/012182.html Change-Id: I36ee53e57e468d760b80a7e621b90899867a8efd --- inc/python | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/inc/python b/inc/python index 32dd72594f..37e8399f4a 100644 --- a/inc/python +++ b/inc/python @@ -162,16 +162,14 @@ function pip_install { local sudo_pip="env" else local cmd_pip - cmd_pip=$(get_pip_command $PYTHON2_VERSION) local sudo_pip="sudo -H" if python3_enabled; then - # Special case some services that have experimental - # support for python3 in progress, but don't claim support - # in their classifier - echo "Check python version for : $package_dir" - echo "Using $PYTHON3_VERSION version to install $package_dir based on default behavior" + echo "Using python $PYTHON3_VERSION to install $package_dir because python3_enabled=True" sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8" cmd_pip=$(get_pip_command $PYTHON3_VERSION) + else + echo "Using python $PYTHON2_VERSION to install $package_dir because python3_enabled=False" + cmd_pip=$(get_pip_command $PYTHON2_VERSION) fi fi @@ -179,16 +177,6 @@ function pip_install { # Always apply constraints cmd_pip="$cmd_pip -c $REQUIREMENTS_DIR/upper-constraints.txt" - # FIXME(dhellmann): Need to force multiple versions of pip for - # packages like setuptools? - local pip_version - pip_version=$(python -c "import pip; \ - print(pip.__version__.split('.')[0])") - if (( pip_version<6 )); then - die $LINENO "Currently installed pip version ${pip_version} does not" \ - "meet minimum requirements (>=6)." - fi - $xtrace # Also install test requirements @@ -225,8 +213,13 @@ function pip_uninstall { local sudo_pip="env" else local cmd_pip - cmd_pip=$(get_pip_command $PYTHON2_VERSION) local sudo_pip="sudo -H" + if python3_enabled; then + sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8" + cmd_pip=$(get_pip_command $PYTHON3_VERSION) + else + cmd_pip=$(get_pip_command $PYTHON2_VERSION) + fi fi # don't error if we can't uninstall, it might not be there $sudo_pip $cmd_pip uninstall -y $name || /bin/true