Skip to content

Commit d7a82f4

Browse files
committed
Drop support for python2
python2 is EOL, let's move on and only support python3. Change-Id: Ieffda4edea9cc19484c04420ed703f7141ef9f15
1 parent f6286cb commit d7a82f4

File tree

8 files changed

+21
-101
lines changed

8 files changed

+21
-101
lines changed

.zuul.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,6 @@
558558
devstack_localrc:
559559
SERVICE_IP_VERSION: 6
560560
SERVICE_HOST: ""
561-
# IPv6 and certificates known issue with python2
562-
# https://bugs.launchpad.net/devstack/+bug/1794929
563-
USE_PYTHON3: true
564561

565562
- job:
566563
name: devstack-multinode

doc/source/configuration.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -430,17 +430,6 @@ Python bindings added when they are enabled.
430430

431431
ADDITIONAL_VENV_PACKAGES="python-foo, python-bar"
432432

433-
Use python2
434-
------------
435-
436-
By default ``stack.sh`` uses python3 (the exact version set by the
437-
``PYTHON3_VERSION``). This can be overriden so devstack will run
438-
python2 (the exact version set by ``PYTHON2_VERSION``).
439-
440-
::
441-
442-
USE_PYTHON3=False
443-
444433
A clean install every time
445434
--------------------------
446435

doc/source/guides/devstack-with-lbaas-v2.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ Edit your ``/opt/stack/devstack/local.conf`` to look like
4141
# If you are enabling barbican for TLS offload in Octavia, include it here.
4242
# enable_plugin barbican https://opendev.org/openstack/barbican
4343

44-
# If you have python3 available:
45-
# USE_PYTHON3=True
46-
4744
# ===== BEGIN localrc =====
4845
DATABASE_PASSWORD=password
4946
ADMIN_PASSWORD=password

inc/python

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -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
460448
function 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
469453
function 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

lib/apache

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ function install_apache_uwsgi {
8989
#
9090
# For package installs, the distro ships both plugins and you need
9191
# to select the right one ... it will not be autodetected.
92-
if python3_enabled; then
93-
UWSGI_PYTHON_PLUGIN=python3
94-
else
95-
UWSGI_PYTHON_PLUGIN=python
96-
fi
92+
UWSGI_PYTHON_PLUGIN=python3
9793

9894
if is_ubuntu; then
9995
local pkg_list="uwsgi uwsgi-plugin-python3 libapache2-mod-proxy-uwsgi"
@@ -150,14 +146,10 @@ function install_apache_wsgi {
150146
if is_ubuntu; then
151147
# Install apache2, which is NOPRIME'd
152148
install_package apache2
153-
if python3_enabled; then
154-
if is_package_installed libapache2-mod-wsgi; then
155-
uninstall_package libapache2-mod-wsgi
156-
fi
157-
install_package libapache2-mod-wsgi-py3
158-
else
159-
install_package libapache2-mod-wsgi
149+
if is_package_installed libapache2-mod-wsgi; then
150+
uninstall_package libapache2-mod-wsgi
160151
fi
152+
install_package libapache2-mod-wsgi-py3
161153
elif is_fedora; then
162154
sudo rm -f /etc/httpd/conf.d/000-*
163155
install_package httpd mod_wsgi

lib/tls

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,7 @@ function init_CA {
227227
function init_cert {
228228
if [[ ! -r $DEVSTACK_CERT ]]; then
229229
if [[ -n "$TLS_IP" ]]; then
230-
if python3_enabled; then
231-
TLS_IP="IP:$TLS_IP"
232-
else
233-
# Lie to let incomplete match routines work with python2
234-
# see https://bugs.python.org/issue23239
235-
TLS_IP="DNS:$TLS_IP,IP:$TLS_IP"
236-
fi
230+
TLS_IP="IP:$TLS_IP"
237231
if [[ -n "$HOST_IPV6" ]]; then
238232
TLS_IP="$TLS_IP,IP:$HOST_IPV6"
239233
fi

stackrc

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,17 @@ if [[ -r $RC_DIR/.localrc.password ]]; then
134134
fi
135135

136136
# Control whether Python 3 should be used at all.
137-
export USE_PYTHON3=$(trueorfalse True USE_PYTHON3)
137+
# TODO(frickler): Drop this when all consumers are fixed
138+
export USE_PYTHON3=True
138139

139-
# When Python 3 is supported by an application, adding the specific
140-
# version of Python 3 to this variable will install the app using that
141-
# version of the interpreter instead of 2.7.
140+
# Adding the specific version of Python 3 to this variable will install
141+
# the app using that version of the interpreter instead of just 3.
142142
_DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)"
143143
export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3}}
144144

145-
# Just to be more explicit on the Python 2 version to use.
146-
_DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"
147-
export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION:-2.7}}
148-
149145
# Create a virtualenv with this
150-
if [[ ${USE_PYTHON3} == True ]]; then
151-
# Use the built-in venv to avoid more dependencies
152-
export VIRTUALENV_CMD="python3 -m venv"
153-
else
154-
export VIRTUALENV_CMD="virtualenv "
155-
fi
146+
# Use the built-in venv to avoid more dependencies
147+
export VIRTUALENV_CMD="python3 -m venv"
156148

157149
# Default for log coloring is based on interactive-or-not.
158150
# Baseline assumption is that non-interactive invocations are for CI,

tools/install_pip.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ function install_get_pip {
9292
touch $LOCAL_PIP.downloaded
9393
fi
9494
sudo -H -E python${PYTHON3_VERSION} $LOCAL_PIP
95-
if ! python3_enabled; then
96-
sudo -H -E python $LOCAL_PIP
97-
fi
9895
}
9996

10097

@@ -142,9 +139,6 @@ fi
142139
# results in a nonfunctional system. pip on fedora installs to /usr so pip
143140
# can safely override the system pip for all versions of fedora
144141
if ! is_fedora && ! is_suse; then
145-
if is_package_installed python-pip ; then
146-
uninstall_package python-pip
147-
fi
148142
if is_package_installed python3-pip ; then
149143
uninstall_package python3-pip
150144
fi

0 commit comments

Comments
 (0)