From 179e6287b16e28eaffedfe512d64d9f8091173a5 Mon Sep 17 00:00:00 2001
From: Ian Stapleton Cordasco <icordasco@heroku.com>
Date: Fri, 6 Jul 2018 08:52:10 -0500
Subject: [PATCH] Prevent Python 3.7 from being unsupported

Python 3.7.0 is supported but not preferred given how new it is. As a
result, we don't want it to be the default, but we also don't want users
to be confused when upgrading to it.

Closes gh-728
---
 bin/compile                     |  5 +++--
 bin/steps/pipenv-python-version |  5 ++++-
 bin/steps/python                | 13 +++++++++----
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/bin/compile b/bin/compile
index de41aa74..f173fdee 100755
--- a/bin/compile
+++ b/bin/compile
@@ -50,7 +50,8 @@ export VENDOR_URL
 # as well as prompt the user to upgrade if they are using an un–supported version.
 # Note: When 3.7 lands, I recommend switching to LATEST_36 and LATEST_37.
 DEFAULT_PYTHON_VERSION="python-3.6.6"
-LATEST_3="python-3.6.6"
+LATEST_36="python-3.6.6"
+LATEST_37="python-3.7.0"
 LATEST_2="python-2.7.15"
 
 # Which stack is used (for binary downloading), if none is provided (e.g. outside of Heroku)?
@@ -58,7 +59,7 @@ DEFAULT_PYTHON_STACK="cedar-14"
 # If pip doesn't match this version (the version we install), run the installer.
 PIP_UPDATE="9.0.2"
 
-export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE LATEST_2 LATEST_3
+export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE LATEST_2 LATEST_36 LATEST_37
 
 # Common Problem Warnings:
 # This section creates a temporary file in which to stick the output of `pip install`.
diff --git a/bin/steps/pipenv-python-version b/bin/steps/pipenv-python-version
index d8f6f16f..c8ee06db 100755
--- a/bin/steps/pipenv-python-version
+++ b/bin/steps/pipenv-python-version
@@ -22,7 +22,10 @@ if [[ -f $BUILD_DIR/Pipfile ]]; then
                     echo "$LATEST_2" > "$BUILD_DIR/runtime.txt"
                 fi
                 if [ "$PYTHON" = 3.6 ]; then
-                    echo "$LATEST_3" > "$BUILD_DIR/runtime.txt"
+                    echo "$LATEST_36" > "$BUILD_DIR/runtime.txt"
+                fi
+                if [ "$PYTHON" = 3.7 ]; then
+                    echo "$LATEST_37" > "$BUILD_DIR/runtime.txt"
                 fi
             fi
 
diff --git a/bin/steps/python b/bin/steps/python
index 0ed98404..77df5909 100755
--- a/bin/steps/python
+++ b/bin/steps/python
@@ -14,12 +14,17 @@ if [[ $PYTHON_VERSION =~ ^python-2 ]]; then
     echo "       Learn More: https://devcenter.heroku.com/articles/python-runtimes"
   fi
 else
-  if [[ "$PYTHON_VERSION" != "$LATEST_3" ]]; then
-    puts-warn "The latest version of Python 3 is $LATEST_3 (you are using $PYTHON_VERSION, which is unsupported)."
-    puts-warn "We recommend upgrading by specifying the latest version ($LATEST_3)."
+  if [[ $PYTHON_VERSION =~ ^python-3.7 ]] && [[ "$PYTHON_VERSION" != "$LATEST_37" ]]; then
+    puts-warn "The latest version of Python 3 is $LATEST_37 (you are using $PYTHON_VERSION, which is unsupported)."
+    puts-warn "We recommend upgrading by specifying the latest version ($LATEST_37)."
     echo "       Learn More: https://devcenter.heroku.com/articles/python-runtimes"
+  else
+    if [[ "$PYTHON_VERSION" != "$LATEST_36" ]]; then
+      puts-warn "The latest version of Python 3 is $LATEST_36 (you are using $PYTHON_VERSION, which is unsupported)."
+      puts-warn "We recommend upgrading by specifying the latest version ($LATEST_36)."
+      echo "       Learn More: https://devcenter.heroku.com/articles/python-runtimes"
+    fi
   fi
-
 fi
 
 if [[ "$STACK" != "$CACHED_PYTHON_STACK" ]]; then
-- 
GitLab