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
... | ... |
@@ -2380,13 +2380,28 @@ function is_provider_network { |
2380 | 2380 |
} |
2381 | 2381 |
|
2382 | 2382 |
|
2383 |
+# Return just the <major>.<minor> for the given python interpreter |
|
2384 |
+function _get_python_version { |
|
2385 |
+ local interp=$1 |
|
2386 |
+ local version |
|
2387 |
+ version=$($interp -c 'import sys; print("%s.%s" % sys.version_info[0:2])') |
|
2388 |
+ echo ${version} |
|
2389 |
+} |
|
2390 |
+ |
|
2383 | 2391 |
# Return the current python as "python<major>.<minor>" |
2384 | 2392 |
function python_version { |
2385 | 2393 |
local python_version |
2386 |
- python_version=$(python -c 'import sys; print("%s.%s" % sys.version_info[0:2])') |
|
2394 |
+ python_version=$(_get_python_version python2) |
|
2395 |
+ echo "python${python_version}" |
|
2396 |
+} |
|
2397 |
+ |
|
2398 |
+function python3_version { |
|
2399 |
+ local python3_version |
|
2400 |
+ python3_version=$(_get_python_version python3) |
|
2387 | 2401 |
echo "python${python_version}" |
2388 | 2402 |
} |
2389 | 2403 |
|
2404 |
+ |
|
2390 | 2405 |
# Service wrapper to restart services |
2391 | 2406 |
# restart_service service-name |
2392 | 2407 |
function restart_service { |
... | ... |
@@ -153,10 +153,12 @@ export DISABLED_PYTHON3_PACKAGES="" |
153 | 153 |
# When Python 3 is supported by an application, adding the specific |
154 | 154 |
# version of Python 3 to this variable will install the app using that |
155 | 155 |
# version of the interpreter instead of 2.7. |
156 |
-export PYTHON3_VERSION=${PYTHON3_VERSION:-3.5} |
|
156 |
+_DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)" |
|
157 |
+export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION}} |
|
157 | 158 |
|
158 | 159 |
# Just to be more explicit on the Python 2 version to use. |
159 |
-export PYTHON2_VERSION=${PYTHON2_VERSION:-2.7} |
|
160 |
+_DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)" |
|
161 |
+export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION}} |
|
160 | 162 |
|
161 | 163 |
# allow local overrides of env variables, including repo config |
162 | 164 |
if [[ -f $RC_DIR/localrc ]]; then |