From fd19ec2c6a5a29ea67d0d085f473402a7f86cbea Mon Sep 17 00:00:00 2001
From: Kenneth Reitz <me@kennethreitz.com>
Date: Fri, 1 Aug 2014 18:00:49 -0400
Subject: [PATCH] support for cryptography!

---
 bin/compile            |  3 +++
 bin/steps/cryptography | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100755 bin/steps/cryptography

diff --git a/bin/compile b/bin/compile
index 591b2f93..0e076d79 100755
--- a/bin/compile
+++ b/bin/compile
@@ -159,6 +159,9 @@ source $BIN_DIR/steps/mercurial
 # Pylibmc support.
 source $BIN_DIR/steps/pylibmc
 
+# Libffi support.
+source $BIN_DIR/steps/cryptography
+
 # Install dependencies with Pip.
 source $BIN_DIR/steps/pip-install
 
diff --git a/bin/steps/cryptography b/bin/steps/cryptography
new file mode 100755
index 00000000..a56d4c30
--- /dev/null
+++ b/bin/steps/cryptography
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+# This script serves as the Pylibmc build step of the
+# [**Python Buildpack**](https://github.com/heroku/heroku-buildpack-python)
+# compiler.
+#
+# A [buildpack](http://devcenter.heroku.com/articles/buildpacks) is an
+# adapter between a Python application and Heroku's runtime.
+#
+# This script is invoked by [`bin/compile`](/).
+
+# The location of the pre-compiled cryptography binary.
+VENDORED_LIBFFI="http://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libffi.tar.gz"
+
+PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
+
+# Syntax sugar.
+source $BIN_DIR/utils
+
+bpwatch start libffi_install
+
+whereis pkg-config
+
+# If pylibmc exists within requirements, use vendored cryptography.
+if (pip-grep -s requirements.txt cffi pylibmc) then
+
+  if [ -d ".heroku/vendor/lib/libffi-3.1.1" ]; then
+    export LIBFFI=$(pwd)/vendor
+  else
+    echo "-----> Noticed cffi. Bootstrapping libffi."
+    mkdir -p .heroku/vendor
+    # Download and extract cryptography into target vendor directory.
+    curl $VENDORED_LIBFFI -s | tar zxv -C .heroku/vendor &> /dev/null
+
+    export LIBFFI=$(pwd)/vendor
+  fi
+fi
+
+bpwatch stop libffi_install
-- 
GitLab