From 919090083b4cd4a09efa573851d8bac43dcf5422 Mon Sep 17 00:00:00 2001
From: Ian Stapleton Cordasco <icordasco@heroku.com>
Date: Tue, 10 Jul 2018 11:24:44 -0500
Subject: [PATCH] Allow users to override the version of pipenv used

This also starts tracking which Pipenv version users are selecting to
use.

Closes #702
Closes #704
Closes #706
Closes #727
---
 CHANGELOG.md     |  7 +++++++
 bin/steps/pipenv | 17 +++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9441c534..77117d85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
 # Python Buildpack Changelog
 
+# Unreleased
+
+- Fix bug with the "latest version" message on 3.7.0
+- Add an `OVERRIDDEN_PIPENV_VERSION` option to override the version of Pipenv
+  used in the buildpack
+- Upgrade the `DEFAULT_PIPENV_VERSION` to `2018.7.1`
+
 # 136
 
 Upgrade to 3.6.6 and support 3.7.0 on all runtimes.
diff --git a/bin/steps/pipenv b/bin/steps/pipenv
index 408f0150..405fae92 100755
--- a/bin/steps/pipenv
+++ b/bin/steps/pipenv
@@ -6,21 +6,19 @@
 source "$BIN_DIR/utils"
 set -e
 
+export DEFAULT_PIPENV_VERSION="2018.7.1"
+
 if [[ -f Pipfile.lock ]]; then
     if [[ -f .heroku/python/Pipfile.lock.sha256 ]]; then
         if [[ $(openssl dgst -sha256 Pipfile.lock) == $(cat .heroku/python/Pipfile.lock.sha256) ]]; then
-            # Measure that we're using Pipenv.
-            mcount "tool.pipenv"
-
             # Don't skip installation of there are git deps.
             if ! grep -q 'git' Pipfile.lock; then
                 echo "Skipping installation, as Pipfile.lock hasn't changed since last deploy." | indent
 
-                mcount "tool.pipenv"
                 export SKIP_PIPENV_INSTALL=1
                 export SKIP_PIP_INSTALL=1
             fi
-
+            mcount "tool.pipenv"
         fi
     fi
 fi
@@ -29,9 +27,6 @@ fi
 if [ ! "$SKIP_PIPENV_INSTALL" ]; then
     # Pipenv support (Generate requriements.txt with pipenv).
     if [[ -f Pipfile ]]; then
-        # Measure that we're using Pipenv.
-        mcount "tool.pipenv"
-
         # Skip pip install, later.
         export SKIP_PIP_INSTALL=1
 
@@ -41,10 +36,12 @@ if [ ! "$SKIP_PIPENV_INSTALL" ]; then
             export PIP_EXTRA_INDEX_URL
         fi
 
-        export PIPENV_VERSION="2018.7.1"
+        export PIPENV_VERSION="${OVERRIDDEN_PIPENV_VERSION:-$DEFAULT_PIPENV_VERSION}"
+        mcount "tool.pipenv"
+        mcount "version.pipenv.$PIPENV_VERSION"
 
         # Install pipenv.
-        /app/.heroku/python/bin/pip install pipenv==$PIPENV_VERSION --upgrade &> /dev/null
+        /app/.heroku/python/bin/pip install "pipenv==$PIPENV_VERSION" --upgrade &> /dev/null
 
         # Install the dependencies.
         if [[ ! -f Pipfile.lock ]]; then
-- 
GitLab