Skip to content

Commit afa8a00

Browse files
committed
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
1 parent 2989054 commit afa8a00

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

inc/python

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ function get_python_versions_for_package {
7676
| grep 'Language' | cut -f5 -d: | grep '\.' | tr '\n' ' '
7777
}
7878

79+
# Check for python3 classifier in local directory
80+
function check_python3_support_for_package_local {
81+
local name=$1
82+
cd $name
83+
set +e
84+
classifier=$(python setup.py --classifiers \
85+
| grep 'Programming Language :: Python :: 3$')
86+
set -e
87+
echo $classifier
88+
}
89+
90+
# Check for python3 classifier on pypi
91+
function check_python3_support_for_package_remote {
92+
local name=$1
93+
set +e
94+
classifier=$(curl -s -L "https://pypi.python.org/pypi/$name/json" \
95+
| grep '"Programming Language :: Python :: 3"')
96+
set -e
97+
echo $classifier
98+
}
99+
79100
# Wrapper for ``pip install`` to set cache and proxy environment variables
80101
# Uses globals ``OFFLINE``, ``PIP_VIRTUAL_ENV``,
81102
# ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``,
@@ -123,9 +144,39 @@ function pip_install {
123144
# default pip
124145
local package_dir=${!#}
125146
local python_versions
126-
if [[ -d "$package_dir" ]]; then
147+
148+
# Special case some services that have experimental
149+
# support for python3 in progress, but don't claim support
150+
# in their classifier
151+
echo "Check python version for : $package_dir"
152+
if [[ ${package_dir##*/} == "nova" || ${package_dir##*/} == "glance" || ${package_dir##*/} == "cinder" ]]; then
153+
echo "Using $PYTHON3_VERSION version to install $package_dir"
154+
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
155+
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
156+
elif [[ -d "$package_dir" ]]; then
127157
python_versions=$(get_python_versions_for_package $package_dir)
128158
if [[ $python_versions =~ $PYTHON3_VERSION ]]; then
159+
echo "Using $PYTHON3_VERSION version to install $package_dir"
160+
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
161+
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
162+
else
163+
# The package may not have yet advertised python3.5
164+
# support so check for just python3 classifier and log
165+
# a warning.
166+
python3_classifier=$(check_python3_support_for_package_local $package_dir)
167+
if [[ ! -z "$python3_classifier" ]]; then
168+
echo "Using $PYTHON3_VERSION version to install $package_dir"
169+
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
170+
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
171+
fi
172+
fi
173+
else
174+
# Check pypi as we don't have the package on disk
175+
package=$(echo $package_dir | grep -o '^[.a-zA-Z0-9_-]*')
176+
python3_classifier=$(check_python3_support_for_package_remote $package)
177+
if [[ ! -z "$python3_classifier" ]]; then
178+
echo "Using $PYTHON3_VERSION version to install $package"
179+
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
129180
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
130181
fi
131182
fi

lib/apache

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ function install_apache_wsgi {
7171
# Apache installation, because we mark it NOPRIME
7272
if is_ubuntu; then
7373
# Install apache2, which is NOPRIME'd
74-
install_package apache2 libapache2-mod-wsgi
74+
install_package apache2
75+
if python3_enabled; then
76+
if is_package_installed libapache2-mod-wsgi; then
77+
uninstall_package libapache2-mod-wsgi
78+
fi
79+
install_package libapache2-mod-wsgi-py3
80+
else
81+
install_package libapache2-mod-wsgi
82+
fi
7583
elif is_fedora; then
7684
sudo rm -f /etc/httpd/conf.d/000-*
7785
install_package httpd mod_wsgi

lib/horizon

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ function configure_horizon {
8181
# Horizon is installed as develop mode, so we can compile here.
8282
# Message catalog compilation is handled by Django admin script,
8383
# so compiling them after the installation avoids Django installation twice.
84-
(cd $HORIZON_DIR; python manage.py compilemessages)
84+
if python3_enabled; then
85+
(cd $HORIZON_DIR; python${PYTHON3_VERSION} manage.py compilemessages)
86+
else
87+
(cd $HORIZON_DIR; python manage.py compilemessages)
88+
fi
8589

8690
# ``local_settings.py`` is used to override horizon default settings.
8791
local local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py
@@ -162,7 +166,11 @@ function install_django_openstack_auth {
162166
git_clone_by_name "django_openstack_auth"
163167
# Compile message catalogs before installation
164168
_prepare_message_catalog_compilation
165-
(cd $dir; python setup.py compile_catalog)
169+
if python3_enabled; then
170+
(cd $dir; python${PYTHON3_VERSION} setup.py compile_catalog)
171+
else
172+
(cd $dir; python setup.py compile_catalog)
173+
fi
166174
setup_dev_lib "django_openstack_auth"
167175
fi
168176
# if we aren't using this library from git, then we just let it

stackrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ if [[ -r $RC_DIR/.localrc.password ]]; then
101101
fi
102102

103103
# Control whether Python 3 should be used.
104-
export USE_PYTHON3=${USE_PYTHON3:-False}
104+
export USE_PYTHON3=$(trueorfalse False USE_PYTHON3)
105105

106106
# When Python 3 is supported by an application, adding the specific
107107
# version of Python 3 to this variable will install the app using that
108108
# version of the interpreter instead of 2.7.
109-
export PYTHON3_VERSION=${PYTHON3_VERSION:-3.4}
109+
export PYTHON3_VERSION=${PYTHON3_VERSION:-3.5}
110110

111111
# Just to be more explicit on the Python 2 version to use.
112112
export PYTHON2_VERSION=${PYTHON2_VERSION:-2.7}

0 commit comments

Comments
 (0)