Drop support for python2
python2 is EOL, let's move on and only support python3. Change-Id: Ieffda4edea9cc19484c04420ed703f7141ef9f15
This commit is contained in:
parent
f6286cb586
commit
d7a82f41e4
@ -558,9 +558,6 @@
|
||||
devstack_localrc:
|
||||
SERVICE_IP_VERSION: 6
|
||||
SERVICE_HOST: ""
|
||||
# IPv6 and certificates known issue with python2
|
||||
# https://bugs.launchpad.net/devstack/+bug/1794929
|
||||
USE_PYTHON3: true
|
||||
|
||||
- job:
|
||||
name: devstack-multinode
|
||||
|
@ -430,17 +430,6 @@ Python bindings added when they are enabled.
|
||||
|
||||
ADDITIONAL_VENV_PACKAGES="python-foo, python-bar"
|
||||
|
||||
Use python2
|
||||
------------
|
||||
|
||||
By default ``stack.sh`` uses python3 (the exact version set by the
|
||||
``PYTHON3_VERSION``). This can be overriden so devstack will run
|
||||
python2 (the exact version set by ``PYTHON2_VERSION``).
|
||||
|
||||
::
|
||||
|
||||
USE_PYTHON3=False
|
||||
|
||||
A clean install every time
|
||||
--------------------------
|
||||
|
||||
|
@ -41,9 +41,6 @@ Edit your ``/opt/stack/devstack/local.conf`` to look like
|
||||
# If you are enabling barbican for TLS offload in Octavia, include it here.
|
||||
# enable_plugin barbican https://opendev.org/openstack/barbican
|
||||
|
||||
# If you have python3 available:
|
||||
# USE_PYTHON3=True
|
||||
|
||||
# ===== BEGIN localrc =====
|
||||
DATABASE_PASSWORD=password
|
||||
ADMIN_PASSWORD=password
|
||||
|
55
inc/python
55
inc/python
@ -62,7 +62,7 @@ function get_python_exec_prefix {
|
||||
$xtrace
|
||||
|
||||
local PYTHON_PATH=/usr/local/bin
|
||||
( is_fedora && ! python3_enabled ) || is_suse && PYTHON_PATH=/usr/bin
|
||||
is_suse && PYTHON_PATH=/usr/bin
|
||||
echo $PYTHON_PATH
|
||||
}
|
||||
|
||||
@ -169,16 +169,9 @@ function pip_install {
|
||||
local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
|
||||
local sudo_pip="env"
|
||||
else
|
||||
local cmd_pip
|
||||
local sudo_pip="sudo -H"
|
||||
if python3_enabled; then
|
||||
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="python$PYTHON3_VERSION -m pip"
|
||||
else
|
||||
echo "Using python $PYTHON2_VERSION to install $package_dir because python3_enabled=False"
|
||||
cmd_pip=$(get_pip_command $PYTHON2_VERSION)
|
||||
fi
|
||||
local cmd_pip="python$PYTHON3_VERSION -m pip"
|
||||
local sudo_pip="sudo -H LC_ALL=en_US.UTF-8"
|
||||
echo "Using python $PYTHON3_VERSION to install $package_dir"
|
||||
fi
|
||||
|
||||
cmd_pip="$cmd_pip install"
|
||||
@ -213,14 +206,8 @@ function pip_uninstall {
|
||||
local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
|
||||
local sudo_pip="env"
|
||||
else
|
||||
local cmd_pip
|
||||
local sudo_pip="sudo -H"
|
||||
if python3_enabled; then
|
||||
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
|
||||
cmd_pip="python$PYTHON3_VERSION -m pip"
|
||||
else
|
||||
cmd_pip=$(get_pip_command $PYTHON2_VERSION)
|
||||
fi
|
||||
local cmd_pip="python$PYTHON3_VERSION -m pip"
|
||||
local sudo_pip="sudo -H LC_ALL=en_US.UTF-8"
|
||||
fi
|
||||
# don't error if we can't uninstall, it might not be there
|
||||
$sudo_pip $cmd_pip uninstall -y $name || /bin/true
|
||||
@ -457,37 +444,15 @@ function setup_package {
|
||||
}
|
||||
|
||||
# Report whether python 3 should be used
|
||||
# TODO(frickler): drop this once all legacy uses are removed
|
||||
function python3_enabled {
|
||||
if [[ $USE_PYTHON3 == "True" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Provide requested python version and sets PYTHON variable
|
||||
function install_python {
|
||||
# NOTE: install_python function should finally just do what install_python3
|
||||
# does as soon Python 2 support has been dropped
|
||||
if python3_enabled; then
|
||||
install_python3
|
||||
export PYTHON=$(which python${PYTHON3_VERSION} 2>/dev/null ||
|
||||
which python3 2>/dev/null)
|
||||
if [[ "${DISTRO}" =~ (rhel8) ]]; then
|
||||
# Use Python 3 as default python command so that we have only one
|
||||
# python alternative to use on the system for either python and
|
||||
# python3
|
||||
sudo alternatives --set python "${PYTHON}"
|
||||
else
|
||||
# Install anyway Python 2 for legacy scripts that still requires
|
||||
# python instead of python3 command
|
||||
install_package python
|
||||
fi
|
||||
else
|
||||
echo "WARNING - Python 2 support has been deprecated in favor of Python 3"
|
||||
install_package python
|
||||
export PYTHON=$(which python 2>/dev/null)
|
||||
fi
|
||||
install_python3
|
||||
export PYTHON=$(which python${PYTHON3_VERSION} 2>/dev/null)
|
||||
}
|
||||
|
||||
# Install python3 packages
|
||||
|
16
lib/apache
16
lib/apache
@ -89,11 +89,7 @@ function install_apache_uwsgi {
|
||||
#
|
||||
# For package installs, the distro ships both plugins and you need
|
||||
# to select the right one ... it will not be autodetected.
|
||||
if python3_enabled; then
|
||||
UWSGI_PYTHON_PLUGIN=python3
|
||||
else
|
||||
UWSGI_PYTHON_PLUGIN=python
|
||||
fi
|
||||
UWSGI_PYTHON_PLUGIN=python3
|
||||
|
||||
if is_ubuntu; then
|
||||
local pkg_list="uwsgi uwsgi-plugin-python3 libapache2-mod-proxy-uwsgi"
|
||||
@ -150,14 +146,10 @@ function install_apache_wsgi {
|
||||
if is_ubuntu; then
|
||||
# Install apache2, which is NOPRIME'd
|
||||
install_package apache2
|
||||
if python3_enabled; then
|
||||
if is_package_installed libapache2-mod-wsgi; then
|
||||
uninstall_package libapache2-mod-wsgi
|
||||
fi
|
||||
install_package libapache2-mod-wsgi-py3
|
||||
else
|
||||
install_package libapache2-mod-wsgi
|
||||
if is_package_installed libapache2-mod-wsgi; then
|
||||
uninstall_package libapache2-mod-wsgi
|
||||
fi
|
||||
install_package libapache2-mod-wsgi-py3
|
||||
elif is_fedora; then
|
||||
sudo rm -f /etc/httpd/conf.d/000-*
|
||||
install_package httpd mod_wsgi
|
||||
|
8
lib/tls
8
lib/tls
@ -227,13 +227,7 @@ function init_CA {
|
||||
function init_cert {
|
||||
if [[ ! -r $DEVSTACK_CERT ]]; then
|
||||
if [[ -n "$TLS_IP" ]]; then
|
||||
if python3_enabled; then
|
||||
TLS_IP="IP:$TLS_IP"
|
||||
else
|
||||
# Lie to let incomplete match routines work with python2
|
||||
# see https://bugs.python.org/issue23239
|
||||
TLS_IP="DNS:$TLS_IP,IP:$TLS_IP"
|
||||
fi
|
||||
TLS_IP="IP:$TLS_IP"
|
||||
if [[ -n "$HOST_IPV6" ]]; then
|
||||
TLS_IP="$TLS_IP,IP:$HOST_IPV6"
|
||||
fi
|
||||
|
20
stackrc
20
stackrc
@ -134,25 +134,17 @@ if [[ -r $RC_DIR/.localrc.password ]]; then
|
||||
fi
|
||||
|
||||
# Control whether Python 3 should be used at all.
|
||||
export USE_PYTHON3=$(trueorfalse True USE_PYTHON3)
|
||||
# TODO(frickler): Drop this when all consumers are fixed
|
||||
export USE_PYTHON3=True
|
||||
|
||||
# When Python 3 is supported by an application, adding the specific
|
||||
# version of Python 3 to this variable will install the app using that
|
||||
# version of the interpreter instead of 2.7.
|
||||
# Adding the specific version of Python 3 to this variable will install
|
||||
# the app using that version of the interpreter instead of just 3.
|
||||
_DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)"
|
||||
export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3}}
|
||||
|
||||
# Just to be more explicit on the Python 2 version to use.
|
||||
_DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"
|
||||
export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION:-2.7}}
|
||||
|
||||
# Create a virtualenv with this
|
||||
if [[ ${USE_PYTHON3} == True ]]; then
|
||||
# Use the built-in venv to avoid more dependencies
|
||||
export VIRTUALENV_CMD="python3 -m venv"
|
||||
else
|
||||
export VIRTUALENV_CMD="virtualenv "
|
||||
fi
|
||||
# Use the built-in venv to avoid more dependencies
|
||||
export VIRTUALENV_CMD="python3 -m venv"
|
||||
|
||||
# Default for log coloring is based on interactive-or-not.
|
||||
# Baseline assumption is that non-interactive invocations are for CI,
|
||||
|
@ -92,9 +92,6 @@ function install_get_pip {
|
||||
touch $LOCAL_PIP.downloaded
|
||||
fi
|
||||
sudo -H -E python${PYTHON3_VERSION} $LOCAL_PIP
|
||||
if ! python3_enabled; then
|
||||
sudo -H -E python $LOCAL_PIP
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -142,9 +139,6 @@ fi
|
||||
# results in a nonfunctional system. pip on fedora installs to /usr so pip
|
||||
# can safely override the system pip for all versions of fedora
|
||||
if ! is_fedora && ! is_suse; then
|
||||
if is_package_installed python-pip ; then
|
||||
uninstall_package python-pip
|
||||
fi
|
||||
if is_package_installed python3-pip ; then
|
||||
uninstall_package python3-pip
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user