Get default python versions from interpreter

Query the python2/python3 interpreter for it's version to fill in
PYTHON3_VERSION and PYTHON2_VERSION defaults.  This means on a
python3.6 platform such as Fedora 26, we don't need to override the
default.

Change-Id: Id826f275b99b9f397b95e817941019fc503daa1d
diff --git a/functions-common b/functions-common
index 660df79..8505488 100644
--- a/functions-common
+++ b/functions-common
@@ -2380,13 +2380,28 @@
 }
 
 
+# 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>"
 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 b123d8a..625ce3f 100644
--- a/stackrc
+++ b/stackrc
@@ -153,10 +153,12 @@
 # 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