From dd707c21e3998af3d6b40a2ec9e0124845ca71a2 Mon Sep 17 00:00:00 2001
From: Kenneth Reitz <me@kennethreitz.org>
Date: Mon, 19 Dec 2016 15:40:35 -0500
Subject: [PATCH] re-write egg-links

---
 bin/compile           | 8 +-------
 bin/steps/pip-install | 3 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/bin/compile b/bin/compile
index 0ef5bc66..b1061071 100755
--- a/bin/compile
+++ b/bin/compile
@@ -146,16 +146,13 @@ bpwatch stop restore_cache
 
 mkdir -p $(dirname $PROFILE_PATH)
 
-# Make the directory for -e pip installations.
-mkdir -p /app/.heroku/src
-
 if [[ $BUILD_DIR != '/app' ]]; then
   # python expects to reside in /app, so set up symlinks
   # we will not remove these later so subsequent buildpacks can still invoke it
   ln -s $BUILD_DIR/.heroku/python /app/.heroku/python
   ln -s $BUILD_DIR/.heroku/vendor /app/.heroku/vendor
   ln -s $BUILD_DIR/.heroku/venv /app/.heroku/venv
-  # NOTE: /app/.heroku/src also exists, but is copied manually later.
+  ln -s $BUILD_DIR/.heroku/src /app/.heroku/src
 fi
 
 # Install Python.
@@ -202,9 +199,6 @@ set-default-env PYTHONPATH /app/
 # Install sane-default script for $WEB_CONCURRENCY and $FORWARDED_ALLOW_IPS.
 cp $ROOT_DIR/vendor/python.gunicorn.sh $GUNICORN_PROFILE_PATH
 
-# Deep copy the directory for -e pip installations
-deep-cp /app/.heroku/src $BUILD_DIR/.heroku/src
-
 # Experimental post_compile hook.
 bpwatch start post_compile
   source $BIN_DIR/steps/hooks/post_compile
diff --git a/bin/steps/pip-install b/bin/steps/pip-install
index 7dea3cea..4bdbe1dc 100755
--- a/bin/steps/pip-install
+++ b/bin/steps/pip-install
@@ -20,6 +20,9 @@ fi
 cp requirements.txt .heroku/python/requirements-declared.txt
 /app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt
 
+# Replace egg-links with new paths for /app.
+find .heroku/python/lib/python*/site-packages/ -name "*.egg-link" | xargs -n 1 sed -i -e 's#$(pwd)/#/app/#'
+
 [ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install
 [ "$FRESH_PYTHON" ] && bpwatch stop pip_install_first
 
-- 
GitLab