diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99454ba73f1da2a740bb665a98d06ae747b525b5..9dee4a8f39d335e7b4810b67b6ec7b741699ff94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Python Buildpack Changelog
 
+# Unreleased
+
+Fixed automatic pip uninstall of dependencies removed from requirements.txt.
+
 # 109
 
 Fix output for collectstatic step.
diff --git a/bin/compile b/bin/compile
index 6e16a85526a6e4137f9976b9f5ea9d65f87cafd3..6351c244df8e6d95a8216758e2944068b6acdd1c 100755
--- a/bin/compile
+++ b/bin/compile
@@ -170,16 +170,16 @@ sub-env $BIN_DIR/steps/geo-libs
 # GDAL support.
 source $BIN_DIR/steps/gdal
 
-# Install dependencies with Pip (where the magic happens).
-let start=$(nowms)
-source $BIN_DIR/steps/pip-install
-mtime "pip.install.time" "${start}"
-
 # Uninstall removed dependencies with Pip.
 let start=$(nowms)
 source $BIN_DIR/steps/pip-uninstall
 mtime "pip.uninstall.time" "${start}"
 
+# Install dependencies with Pip (where the magic happens).
+let start=$(nowms)
+source $BIN_DIR/steps/pip-install
+mtime "pip.install.time" "${start}"
+
 # Support for NLTK corpora.
 let start=$(nowms)
 sub-env $BIN_DIR/steps/nltk
diff --git a/test/run b/test/run
index 4185388d5a1364b921e1ceee2eac2a728742d2b1..1e66072aa589e4eb1e563b1bf7ae4f6c5e548c03 100755
--- a/test/run
+++ b/test/run
@@ -62,6 +62,16 @@ testPython3() {
   assertCapturedSuccess
 }
 
+testSmartRequirements() {
+  local cache_dir="$(mktmpdir)"
+  compile "requirements-standard" "$cache_dir"
+  assertFile "requests" ".heroku/python/requirements-declared.txt"
+  assertCapturedSuccess
+  compile "psycopg2" "$cache_dir"
+  assertCaptured "Uninstalling requests"
+  assertFile "psycopg2" ".heroku/python/requirements-declared.txt"
+  assertCapturedSuccess
+}