From 500daaf6fc58c7df6489582398d4f83021badf4b Mon Sep 17 00:00:00 2001
From: Kenneth Reitz <me@kennethreitz.org>
Date: Tue, 16 Jan 2018 13:36:01 -0500
Subject: [PATCH] Pipenv development dependencies (ci) (#633)

* initial stab at pipenv --dev support

* test installation output

* locale fix

* refactor

* fix typo

* fix typo

* ellipsis

* polish
---
 CHANGELOG.md          | 4 ++++
 README.md             | 4 ++--
 bin/steps/pip-install | 8 ++++++++
 bin/steps/pipenv      | 7 ++++++-
 bin/test-compile      | 8 ++++----
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a6a7d7a..f36c0a92 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Python Buildpack Changelog
 
+# 124
+
+Update buildpack to automatically install [dev-packages] (Pipenv) during Heroku CI builds.
+
 # 123
 
 Update gunicorn init.d script to allow overrides.
diff --git a/README.md b/README.md
index df808ebe..7ec68184 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Deploying a Python application couldn't be easier:
     $ git push heroku master
     …
     -----> Python app detected
-    -----> Installing python-3.6.3
+    -----> Installing python-3.6.4
     -----> Installing pip
     -----> Installing requirements with latest pipenv…
            ...
@@ -58,7 +58,7 @@ Or, more specifically:
 
 Runtime options include:
 
-- `python-3.6.3`
+- `python-3.6.4`
 - `python-2.7.14`
 - `pypy-5.7.1` (unsupported, experimental)
 - `pypy3-5.5.1` (unsupported, experimental)
diff --git a/bin/steps/pip-install b/bin/steps/pip-install
index e0d5dd39..be92bd14 100755
--- a/bin/steps/pip-install
+++ b/bin/steps/pip-install
@@ -29,4 +29,12 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
     /app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
 
     echo
+    
+    # Install test dependencies, for CI. 
+    if [ "$INSTALL_TEST" ]; then
+        if [[ -f "$1/requirements-test.txt" ]]; then
+            puts-step "Installing test dependencies…"
+            /app/.heroku/python/bin/pip install -r "$1/requirements-test.txt" --exists-action=w --src=./.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | cleanup | indent
+        fi
+    fi
 fi
diff --git a/bin/steps/pipenv b/bin/steps/pipenv
index 857bcd82..5e050f74 100644
--- a/bin/steps/pipenv
+++ b/bin/steps/pipenv
@@ -16,13 +16,18 @@ if [[ -f Pipfile ]]; then
         # Install pipenv.
         /app/.heroku/python/bin/pip install pipenv --upgrade &> /dev/null
 
+        # Install the dependencies.
         if [[ ! -f Pipfile.lock ]]; then
             /app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent
         else
             /app/.heroku/python/bin/pipenv install --system --deploy 2>&1 | indent
         fi
-        # Install the dependencies.
 
+        # Install the test dependencies, for CI.
+        if [ "$INSTALL_TEST" ]; then
+            puts-step "Installing test dependencies…"
+            /app/.heroku/python/bin/pipenv install --dev --system --deploy 2>&1 | cleanup | indent
+        fi
 
         # Skip pip install, later.
         export SKIP_PIP_INSTALL=1
diff --git a/bin/test-compile b/bin/test-compile
index d19814db..fa4a6580 100755
--- a/bin/test-compile
+++ b/bin/test-compile
@@ -6,8 +6,8 @@ BIN_DIR=$(cd "$(dirname "$0")" || return; pwd) # absolute path
 # shellcheck source=bin/utils
 source "$BIN_DIR/utils"
 
-DISABLE_COLLECTSTATIC=1 "$(dirname "${0:-}")/compile" "$1" "$2" "$3"
+# Locale support for Pipenv.
+export LC_ALL=C.UTF-8
+export LANG=C.UTF-8
 
-if [[ -f "$1/requirements-test.txt" ]]; then
-    /app/.heroku/python/bin/pip install -r "$1/requirements-test.txt" --exists-action=w --src=./.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | cleanup | indent
-fi
+DISABLE_COLLECTSTATIC=1 INSTALL_TEST=1 "$(dirname "${0:-}")/compile" "$1" "$2" "$3"
\ No newline at end of file
-- 
GitLab