From a1ed1d7b42d7a51ee538c0ad8de1051d6a9283f6 Mon Sep 17 00:00:00 2001
From: Kenneth Reitz <me@kennethreitz.org>
Date: Thu, 25 May 2017 10:55:01 -0700
Subject: [PATCH] Faster pipenv (#385)

* skip pip install for pipenv

* better

* improvements

* indent

* chmod +x

* export

* skip uninstall too

* pip freeze

* Revert "skip uninstall too"

This reverts commit faac96f62004f78c3d27a92cd865954fc7a3a53d.

* better comments

* redirect stderr to stdout
---
 bin/steps/pip-install       | 31 +++++++++++++++++--------------
 bin/steps/pipenv            | 13 +++++++++++--
 builds/runtimes/pypy3-5.7.1 |  0
 3 files changed, 28 insertions(+), 16 deletions(-)
 mode change 100644 => 100755 builds/runtimes/pypy3-5.7.1

diff --git a/bin/steps/pip-install b/bin/steps/pip-install
index 349c8958..017f9513 100755
--- a/bin/steps/pip-install
+++ b/bin/steps/pip-install
@@ -1,20 +1,23 @@
-# Install dependencies with Pip.
-puts-step "Installing requirements with pip"
+if [ ! "$SKIP_PIP_INSTALL" ]; then
 
-set +e
-/app/.heroku/python/bin/pip install -r $BUILD_DIR/requirements.txt --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee $WARNINGS_LOG | cleanup | indent
-PIP_STATUS="${PIPESTATUS[0]}"
-set -e
+    # Install dependencies with Pip.
+    puts-step "Installing requirements with pip"
 
-show-warnings
+    set +e
+    /app/.heroku/python/bin/pip install -r $BUILD_DIR/requirements.txt --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee $WARNINGS_LOG | cleanup | indent
+    PIP_STATUS="${PIPESTATUS[0]}"
+    set -e
 
-if [[ ! $PIP_STATUS -eq 0 ]]; then
-    exit 1
-fi
+    show-warnings
 
+    if [[ ! $PIP_STATUS -eq 0 ]]; then
+        exit 1
+    fi
 
-# Smart Requirements handling
-cp requirements.txt .heroku/python/requirements-declared.txt
-/app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
 
-echo
+    # Smart Requirements handling
+    cp requirements.txt .heroku/python/requirements-declared.txt
+    /app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
+
+    echo
+fi
\ No newline at end of file
diff --git a/bin/steps/pipenv b/bin/steps/pipenv
index 7b8aff94..cdb9d18c 100644
--- a/bin/steps/pipenv
+++ b/bin/steps/pipenv
@@ -1,10 +1,19 @@
 # Pipenv support (Generate requriements.txt with pipenv).
 if [[ -f Pipfile ]]; then
     if [[ ! -f requirements.txt ]]; then
-        puts-step "Generating 'requirements.txt' with pipenv"
+        puts-step "Installing requirements with latest pipenv..."
 
+        # Install pipenv.
         /app/.heroku/python/bin/pip install pipenv --upgrade &> /dev/null
 
-        /app/.heroku/python/bin/pipenv lock --requirements --no-hashes > $BUILD_DIR/requirements.txt 2> /dev/null
+        # Install the dependencies.
+        /app/.heroku/python/bin/pipenv install --system 2>&1 | indent
+
+        # Skip pip install, later.
+        export SKIP_PIP_INSTALL=1
+
+        # Pip freeze, for compatibility.
+        /app/.heroku/python/bin/pip freeze > requirements.txt
+
     fi
 fi
\ No newline at end of file
diff --git a/builds/runtimes/pypy3-5.7.1 b/builds/runtimes/pypy3-5.7.1
old mode 100644
new mode 100755
-- 
GitLab