diff --git a/functions-common b/functions-common index 4fc7c6db92..deebdec249 100644 --- a/functions-common +++ b/functions-common @@ -2076,13 +2076,28 @@ function is_provider_network { } +# Return just the . 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." function 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}" } +function python3_version { + local python3_version + python3_version=$(_get_python_version python3) + echo "python${python_version}" +} + + # Service wrapper to restart services # restart_service service-name function restart_service { diff --git a/stackrc b/stackrc index 02f60f7bf1..f6b7382cbe 100644 --- a/stackrc +++ b/stackrc @@ -130,10 +130,12 @@ export DISABLED_PYTHON3_PACKAGES="" # 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. -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. -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 if [[ -f $RC_DIR/localrc ]]; then