From 78cf6f642aea91385dfbe6e1fa594e9f5373e69c Mon Sep 17 00:00:00 2001
From: Terry Wilson <twilson@redhat.com>
Date: Tue, 15 Oct 2019 19:45:09 +0000
Subject: [PATCH] Always install python3 and its dev package

Some distros do not install python3/python3-devel with the minimal
install. F29 doesn't install -devel, and neither Centos 7 or 8
install either. This patch ensures that these packages get installed.

Ideally, PYTHON3_VERSION would be set *after* ensuring that python3
was installed, but it gets a little tricky with all of the includes.
This sets it to 3.6 as nothing uses 3.5 anymore.

Change-Id: I7bdfc408b7c18273639ec26eade475856ac43593
---
 inc/python | 2 ++
 stack.sh   | 5 ++++-
 stackrc    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/inc/python b/inc/python
index 32dd72594f..bf3aacaf8f 100644
--- a/inc/python
+++ b/inc/python
@@ -463,6 +463,8 @@ function install_python3 {
         apt_get install python${PYTHON3_VERSION} python${PYTHON3_VERSION}-dev
     elif is_suse; then
         install_package python3-devel python3-dbm
+    elif is_fedora; then
+        install_package python3 python3-devel
     fi
 }
 
diff --git a/stack.sh b/stack.sh
index 089510fa48..de1499ddd6 100755
--- a/stack.sh
+++ b/stack.sh
@@ -415,8 +415,11 @@ fi
 
 # Ensure python is installed
 # --------------------------
-is_package_installed python || install_package python
+install_python3
 
+if ! python3_enabled; then
+    is_package_installed python || install_package python
+fi
 
 # Configure Logging
 # -----------------
diff --git a/stackrc b/stackrc
index 412aca8f07..6cc328ea60 100644
--- a/stackrc
+++ b/stackrc
@@ -142,7 +142,7 @@ export USE_PYTHON3=$(trueorfalse True USE_PYTHON3)
 # version of Python 3 to this variable will install the app using that
 # version of the interpreter instead of 2.7.
 _DEFAULT_PYTHON3_VERSION="$(_get_python_version python3)"
-export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3.5}}
+export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3.6}}
 
 # Just to be more explicit on the Python 2 version to use.
 _DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"