Switch to python 3.5

Use trueorfalse to normalize the values for USE_PYTHON3

Install 3.5 instead of 3.4 When USE_PYTHON3 is specified.
Also, since not many packages are classified correctly, fallback
to looking for just "Programming Language :: Python :: 3" and
log a message for the package to highlight the problem.

Also special case some services that are *almost* ready

Depends-On: Id48e1b328230fcdf97ed1cb4b97f4c3f9cf6eb8a
Depends-On: Ib7d9aa0e0b74a936002e0eea0b3af05102b06a62
Change-Id: I243ea4b76f0d5ef57a03b5b0798a05468ee6de9b
This commit is contained in:
Davanum Srinivas 2016-12-19 09:51:01 -05:00
parent 2989054992
commit afa8a00c14
4 changed files with 73 additions and 6 deletions

View File

@ -76,6 +76,27 @@ function get_python_versions_for_package {
| grep 'Language' | cut -f5 -d: | grep '\.' | tr '\n' ' ' | grep 'Language' | cut -f5 -d: | grep '\.' | tr '\n' ' '
} }
# Check for python3 classifier in local directory
function check_python3_support_for_package_local {
local name=$1
cd $name
set +e
classifier=$(python setup.py --classifiers \
| grep 'Programming Language :: Python :: 3$')
set -e
echo $classifier
}
# Check for python3 classifier on pypi
function check_python3_support_for_package_remote {
local name=$1
set +e
classifier=$(curl -s -L "https://pypi.python.org/pypi/$name/json" \
| grep '"Programming Language :: Python :: 3"')
set -e
echo $classifier
}
# Wrapper for ``pip install`` to set cache and proxy environment variables # Wrapper for ``pip install`` to set cache and proxy environment variables
# Uses globals ``OFFLINE``, ``PIP_VIRTUAL_ENV``, # Uses globals ``OFFLINE``, ``PIP_VIRTUAL_ENV``,
# ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``, # ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``,
@ -123,9 +144,39 @@ function pip_install {
# default pip # default pip
local package_dir=${!#} local package_dir=${!#}
local python_versions local python_versions
if [[ -d "$package_dir" ]]; 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"
if [[ ${package_dir##*/} == "nova" || ${package_dir##*/} == "glance" || ${package_dir##*/} == "cinder" ]]; then
echo "Using $PYTHON3_VERSION version to install $package_dir"
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
elif [[ -d "$package_dir" ]]; then
python_versions=$(get_python_versions_for_package $package_dir) python_versions=$(get_python_versions_for_package $package_dir)
if [[ $python_versions =~ $PYTHON3_VERSION ]]; then if [[ $python_versions =~ $PYTHON3_VERSION ]]; then
echo "Using $PYTHON3_VERSION version to install $package_dir"
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
else
# The package may not have yet advertised python3.5
# support so check for just python3 classifier and log
# a warning.
python3_classifier=$(check_python3_support_for_package_local $package_dir)
if [[ ! -z "$python3_classifier" ]]; then
echo "Using $PYTHON3_VERSION version to install $package_dir"
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
fi
fi
else
# Check pypi as we don't have the package on disk
package=$(echo $package_dir | grep -o '^[.a-zA-Z0-9_-]*')
python3_classifier=$(check_python3_support_for_package_remote $package)
if [[ ! -z "$python3_classifier" ]]; then
echo "Using $PYTHON3_VERSION version to install $package"
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
cmd_pip=$(get_pip_command $PYTHON3_VERSION) cmd_pip=$(get_pip_command $PYTHON3_VERSION)
fi fi
fi fi

View File

@ -71,7 +71,15 @@ function install_apache_wsgi {
# Apache installation, because we mark it NOPRIME # Apache installation, because we mark it NOPRIME
if is_ubuntu; then if is_ubuntu; then
# Install apache2, which is NOPRIME'd # Install apache2, which is NOPRIME'd
install_package apache2 libapache2-mod-wsgi 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
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

View File

@ -81,7 +81,11 @@ function configure_horizon {
# Horizon is installed as develop mode, so we can compile here. # Horizon is installed as develop mode, so we can compile here.
# Message catalog compilation is handled by Django admin script, # Message catalog compilation is handled by Django admin script,
# so compiling them after the installation avoids Django installation twice. # so compiling them after the installation avoids Django installation twice.
(cd $HORIZON_DIR; python manage.py compilemessages) if python3_enabled; then
(cd $HORIZON_DIR; python${PYTHON3_VERSION} manage.py compilemessages)
else
(cd $HORIZON_DIR; python manage.py compilemessages)
fi
# ``local_settings.py`` is used to override horizon default settings. # ``local_settings.py`` is used to override horizon default settings.
local local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py local local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py
@ -162,7 +166,11 @@ function install_django_openstack_auth {
git_clone_by_name "django_openstack_auth" git_clone_by_name "django_openstack_auth"
# Compile message catalogs before installation # Compile message catalogs before installation
_prepare_message_catalog_compilation _prepare_message_catalog_compilation
(cd $dir; python setup.py compile_catalog) if python3_enabled; then
(cd $dir; python${PYTHON3_VERSION} setup.py compile_catalog)
else
(cd $dir; python setup.py compile_catalog)
fi
setup_dev_lib "django_openstack_auth" setup_dev_lib "django_openstack_auth"
fi fi
# if we aren't using this library from git, then we just let it # if we aren't using this library from git, then we just let it

View File

@ -101,12 +101,12 @@ if [[ -r $RC_DIR/.localrc.password ]]; then
fi fi
# Control whether Python 3 should be used. # Control whether Python 3 should be used.
export USE_PYTHON3=${USE_PYTHON3:-False} export USE_PYTHON3=$(trueorfalse False USE_PYTHON3)
# When Python 3 is supported by an application, adding the specific # 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 Python 3 to this variable will install the app using that
# version of the interpreter instead of 2.7. # version of the interpreter instead of 2.7.
export PYTHON3_VERSION=${PYTHON3_VERSION:-3.4} export PYTHON3_VERSION=${PYTHON3_VERSION:-3.5}
# Just to be more explicit on the Python 2 version to use. # Just to be more explicit on the Python 2 version to use.
export PYTHON2_VERSION=${PYTHON2_VERSION:-2.7} export PYTHON2_VERSION=${PYTHON2_VERSION:-2.7}