Merge "Get default python versions from interpreter"

This commit is contained in:
Jenkins 2017-09-10 16:59:05 +00:00 committed by Gerrit Code Review
commit 5b42dcef5d
2 changed files with 20 additions and 3 deletions

View File

@ -2076,13 +2076,28 @@ function is_provider_network {
} }
# Return just the <major>.<minor> for the given python interpreter
function _get_python_version {
local interp=$1
local version
version=$($interp -c 'import sys; print("%s.%s" % sys.version_info[0:2])')
echo ${version}
}
# Return the current python as "python<major>.<minor>" # Return the current python as "python<major>.<minor>"
function python_version { function python_version {
local python_version local python_version
python_version=$(python -c 'import sys; print("%s.%s" % sys.version_info[0:2])') python_version=$(_get_python_version python2)
echo "python${python_version}" echo "python${python_version}"
} }
function python3_version {
local python3_version
python3_version=$(_get_python_version python3)
echo "python${python_version}"
}
# Service wrapper to restart services # Service wrapper to restart services
# restart_service service-name # restart_service service-name
function restart_service { function restart_service {

View File

@ -130,10 +130,12 @@ export DISABLED_PYTHON3_PACKAGES=""
# 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.5} _DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)"
export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION}}
# 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} _DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"
export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION}}
# allow local overrides of env variables, including repo config # allow local overrides of env variables, including repo config
if [[ -f $RC_DIR/localrc ]]; then if [[ -f $RC_DIR/localrc ]]; then