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:
|
devstack_localrc:
|
||||||
SERVICE_IP_VERSION: 6
|
SERVICE_IP_VERSION: 6
|
||||||
SERVICE_HOST: ""
|
SERVICE_HOST: ""
|
||||||
# IPv6 and certificates known issue with python2
|
|
||||||
# https://bugs.launchpad.net/devstack/+bug/1794929
|
|
||||||
USE_PYTHON3: true
|
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: devstack-multinode
|
name: devstack-multinode
|
||||||
|
@ -430,17 +430,6 @@ Python bindings added when they are enabled.
|
|||||||
|
|
||||||
ADDITIONAL_VENV_PACKAGES="python-foo, python-bar"
|
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
|
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.
|
# If you are enabling barbican for TLS offload in Octavia, include it here.
|
||||||
# enable_plugin barbican https://opendev.org/openstack/barbican
|
# enable_plugin barbican https://opendev.org/openstack/barbican
|
||||||
|
|
||||||
# If you have python3 available:
|
|
||||||
# USE_PYTHON3=True
|
|
||||||
|
|
||||||
# ===== BEGIN localrc =====
|
# ===== BEGIN localrc =====
|
||||||
DATABASE_PASSWORD=password
|
DATABASE_PASSWORD=password
|
||||||
ADMIN_PASSWORD=password
|
ADMIN_PASSWORD=password
|
||||||
|
51
inc/python
51
inc/python
@ -62,7 +62,7 @@ function get_python_exec_prefix {
|
|||||||
$xtrace
|
$xtrace
|
||||||
|
|
||||||
local PYTHON_PATH=/usr/local/bin
|
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
|
echo $PYTHON_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,16 +169,9 @@ function pip_install {
|
|||||||
local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
|
local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
|
||||||
local sudo_pip="env"
|
local sudo_pip="env"
|
||||||
else
|
else
|
||||||
local cmd_pip
|
local cmd_pip="python$PYTHON3_VERSION -m pip"
|
||||||
local sudo_pip="sudo -H"
|
local sudo_pip="sudo -H LC_ALL=en_US.UTF-8"
|
||||||
if python3_enabled; then
|
echo "Using python $PYTHON3_VERSION to install $package_dir"
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmd_pip="$cmd_pip install"
|
cmd_pip="$cmd_pip install"
|
||||||
@ -213,14 +206,8 @@ function pip_uninstall {
|
|||||||
local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
|
local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
|
||||||
local sudo_pip="env"
|
local sudo_pip="env"
|
||||||
else
|
else
|
||||||
local cmd_pip
|
local cmd_pip="python$PYTHON3_VERSION -m pip"
|
||||||
local sudo_pip="sudo -H"
|
local sudo_pip="sudo -H LC_ALL=en_US.UTF-8"
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
# don't error if we can't uninstall, it might not be there
|
# don't error if we can't uninstall, it might not be there
|
||||||
$sudo_pip $cmd_pip uninstall -y $name || /bin/true
|
$sudo_pip $cmd_pip uninstall -y $name || /bin/true
|
||||||
@ -457,37 +444,15 @@ function setup_package {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Report whether python 3 should be used
|
# Report whether python 3 should be used
|
||||||
|
# TODO(frickler): drop this once all legacy uses are removed
|
||||||
function python3_enabled {
|
function python3_enabled {
|
||||||
if [[ $USE_PYTHON3 == "True" ]]; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Provide requested python version and sets PYTHON variable
|
# Provide requested python version and sets PYTHON variable
|
||||||
function install_python {
|
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
|
install_python3
|
||||||
export PYTHON=$(which python${PYTHON3_VERSION} 2>/dev/null ||
|
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 packages
|
# Install python3 packages
|
||||||
|
@ -89,11 +89,7 @@ function install_apache_uwsgi {
|
|||||||
#
|
#
|
||||||
# For package installs, the distro ships both plugins and you need
|
# For package installs, the distro ships both plugins and you need
|
||||||
# to select the right one ... it will not be autodetected.
|
# to select the right one ... it will not be autodetected.
|
||||||
if python3_enabled; then
|
|
||||||
UWSGI_PYTHON_PLUGIN=python3
|
UWSGI_PYTHON_PLUGIN=python3
|
||||||
else
|
|
||||||
UWSGI_PYTHON_PLUGIN=python
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
local pkg_list="uwsgi uwsgi-plugin-python3 libapache2-mod-proxy-uwsgi"
|
local pkg_list="uwsgi uwsgi-plugin-python3 libapache2-mod-proxy-uwsgi"
|
||||||
@ -150,14 +146,10 @@ function install_apache_wsgi {
|
|||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
# Install apache2, which is NOPRIME'd
|
# Install apache2, which is NOPRIME'd
|
||||||
install_package apache2
|
install_package apache2
|
||||||
if python3_enabled; then
|
|
||||||
if is_package_installed libapache2-mod-wsgi; then
|
if is_package_installed libapache2-mod-wsgi; then
|
||||||
uninstall_package libapache2-mod-wsgi
|
uninstall_package libapache2-mod-wsgi
|
||||||
fi
|
fi
|
||||||
install_package libapache2-mod-wsgi-py3
|
install_package libapache2-mod-wsgi-py3
|
||||||
else
|
|
||||||
install_package libapache2-mod-wsgi
|
|
||||||
fi
|
|
||||||
elif is_fedora; then
|
elif is_fedora; then
|
||||||
sudo rm -f /etc/httpd/conf.d/000-*
|
sudo rm -f /etc/httpd/conf.d/000-*
|
||||||
install_package httpd mod_wsgi
|
install_package httpd mod_wsgi
|
||||||
|
6
lib/tls
6
lib/tls
@ -227,13 +227,7 @@ function init_CA {
|
|||||||
function init_cert {
|
function init_cert {
|
||||||
if [[ ! -r $DEVSTACK_CERT ]]; then
|
if [[ ! -r $DEVSTACK_CERT ]]; then
|
||||||
if [[ -n "$TLS_IP" ]]; then
|
if [[ -n "$TLS_IP" ]]; then
|
||||||
if python3_enabled; then
|
|
||||||
TLS_IP="IP:$TLS_IP"
|
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
|
|
||||||
if [[ -n "$HOST_IPV6" ]]; then
|
if [[ -n "$HOST_IPV6" ]]; then
|
||||||
TLS_IP="$TLS_IP,IP:$HOST_IPV6"
|
TLS_IP="$TLS_IP,IP:$HOST_IPV6"
|
||||||
fi
|
fi
|
||||||
|
20
stackrc
20
stackrc
@ -134,25 +134,17 @@ if [[ -r $RC_DIR/.localrc.password ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Control whether Python 3 should be used at all.
|
# 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
|
# Adding the specific version of Python 3 to this variable will install
|
||||||
# version of Python 3 to this variable will install the app using that
|
# the app using that version of the interpreter instead of just 3.
|
||||||
# version of the interpreter instead of 2.7.
|
|
||||||
_DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)"
|
_DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)"
|
||||||
export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3}}
|
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
|
# Create a virtualenv with this
|
||||||
if [[ ${USE_PYTHON3} == True ]]; then
|
# Use the built-in venv to avoid more dependencies
|
||||||
# Use the built-in venv to avoid more dependencies
|
export VIRTUALENV_CMD="python3 -m venv"
|
||||||
export VIRTUALENV_CMD="python3 -m venv"
|
|
||||||
else
|
|
||||||
export VIRTUALENV_CMD="virtualenv "
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Default for log coloring is based on interactive-or-not.
|
# Default for log coloring is based on interactive-or-not.
|
||||||
# Baseline assumption is that non-interactive invocations are for CI,
|
# Baseline assumption is that non-interactive invocations are for CI,
|
||||||
|
@ -92,9 +92,6 @@ function install_get_pip {
|
|||||||
touch $LOCAL_PIP.downloaded
|
touch $LOCAL_PIP.downloaded
|
||||||
fi
|
fi
|
||||||
sudo -H -E python${PYTHON3_VERSION} $LOCAL_PIP
|
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
|
# results in a nonfunctional system. pip on fedora installs to /usr so pip
|
||||||
# can safely override the system pip for all versions of fedora
|
# can safely override the system pip for all versions of fedora
|
||||||
if ! is_fedora && ! is_suse; then
|
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
|
if is_package_installed python3-pip ; then
|
||||||
uninstall_package python3-pip
|
uninstall_package python3-pip
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user