@@ -62,7 +62,7 @@ function get_python_exec_prefix {
6262 $xtrace
6363
6464 local PYTHON_PATH=/usr/local/bin
65- ( is_fedora && ! python3_enabled ) || is_suse && PYTHON_PATH=/usr/bin
65+ is_suse && PYTHON_PATH=/usr/bin
6666 echo $PYTHON_PATH
6767}
6868
@@ -169,16 +169,9 @@ function pip_install {
169169 local cmd_pip=$PIP_VIRTUAL_ENV /bin/pip
170170 local sudo_pip=" env"
171171 else
172- local cmd_pip
173- local sudo_pip=" sudo -H"
174- if python3_enabled; then
175- echo " Using python $PYTHON3_VERSION to install $package_dir because python3_enabled=True"
176- sudo_pip=" $sudo_pip LC_ALL=en_US.UTF-8"
177- cmd_pip=" python$PYTHON3_VERSION -m pip"
178- else
179- echo " Using python $PYTHON2_VERSION to install $package_dir because python3_enabled=False"
180- cmd_pip=$( get_pip_command $PYTHON2_VERSION )
181- fi
172+ local cmd_pip=" python$PYTHON3_VERSION -m pip"
173+ local sudo_pip=" sudo -H LC_ALL=en_US.UTF-8"
174+ echo " Using python $PYTHON3_VERSION to install $package_dir "
182175 fi
183176
184177 cmd_pip=" $cmd_pip install"
@@ -213,14 +206,8 @@ function pip_uninstall {
213206 local cmd_pip=$PIP_VIRTUAL_ENV /bin/pip
214207 local sudo_pip=" env"
215208 else
216- local cmd_pip
217- local sudo_pip=" sudo -H"
218- if python3_enabled; then
219- sudo_pip=" $sudo_pip LC_ALL=en_US.UTF-8"
220- cmd_pip=" python$PYTHON3_VERSION -m pip"
221- else
222- cmd_pip=$( get_pip_command $PYTHON2_VERSION )
223- fi
209+ local cmd_pip=" python$PYTHON3_VERSION -m pip"
210+ local sudo_pip=" sudo -H LC_ALL=en_US.UTF-8"
224211 fi
225212 # don't error if we can't uninstall, it might not be there
226213 $sudo_pip $cmd_pip uninstall -y $name || /bin/true
@@ -457,37 +444,15 @@ function setup_package {
457444}
458445
459446# Report whether python 3 should be used
447+ # TODO(frickler): drop this once all legacy uses are removed
460448function python3_enabled {
461- if [[ $USE_PYTHON3 == " True" ]]; then
462- return 0
463- else
464- return 1
465- fi
449+ return 1
466450}
467451
468452# Provide requested python version and sets PYTHON variable
469453function install_python {
470- # NOTE: install_python function should finally just do what install_python3
471- # does as soon Python 2 support has been dropped
472- if python3_enabled; then
473- install_python3
474- export PYTHON=$( which python${PYTHON3_VERSION} 2> /dev/null ||
475- which python3 2> /dev/null)
476- if [[ " ${DISTRO} " =~ (rhel8) ]]; then
477- # Use Python 3 as default python command so that we have only one
478- # python alternative to use on the system for either python and
479- # python3
480- sudo alternatives --set python " ${PYTHON} "
481- else
482- # Install anyway Python 2 for legacy scripts that still requires
483- # python instead of python3 command
484- install_package python
485- fi
486- else
487- echo " WARNING - Python 2 support has been deprecated in favor of Python 3"
488- install_package python
489- export PYTHON=$( which python 2> /dev/null)
490- fi
454+ install_python3
455+ export PYTHON=$( which python${PYTHON3_VERSION} 2> /dev/null)
491456}
492457
493458# Install python3 packages
0 commit comments