From df7f8f3507389ce76cc0424edec984161a6f4212 Mon Sep 17 00:00:00 2001 From: Ed Morley <edmorley@users.noreply.github.com> Date: Fri, 8 Sep 2017 16:27:46 +0100 Subject: [PATCH] Skip vendoring libffi/libmemcached on Heroku-16 (#465) * Add a test for the cryptography (cffi) compile step Since it's currently untested. * Skip vendoring libffi/libmemcached on Heroku-16 Unlike for Cedar-14, Heroku-16 comes with these packages pre-installed: https://github.com/heroku/stack-images/blob/5a341970cfc1f201014262ad64c3b3e47514f663/heroku-16/installed-packages.txt#L111 https://github.com/heroku/stack-images/blob/5a341970cfc1f201014262ad64c3b3e47514f663/heroku-16/installed-packages.txt#L172 As such the build scripts had already been made a no-op on Heroku-16: https://github.com/heroku/heroku-buildpack-python/blob/fedae5ceda5a42f594012f911c3808dd5dc6fd9e/builds/libraries/vendor/libffi#L6-L9 https://github.com/heroku/heroku-buildpack-python/blob/fedae5ceda5a42f594012f911c3808dd5dc6fd9e/builds/libraries/vendor/libmemcache#L6-L9 ...meaning the Heroku-16 archives for them on S3 contain zero files. However until now, the buildpack was still unnecessarily downloading and extracting these empty archives - and not just on the first compile (like on cedar-14), but every compile since the directory check will never succeed. --- CHANGELOG.md | 4 ++++ bin/steps/cryptography | 7 ++++++- bin/steps/pylibmc | 6 +++++- test/fixtures/cffi/requirements.txt | 1 + test/run | 6 ++++++ 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/cffi/requirements.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index a81a832c..6db4c687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Python Buildpack Changelog +# Unreleased + +The libffi/libmemcached vendoring step is now skipped on Heroku-16 (since they are installed in the base image). + # 115 Revert a pull request. diff --git a/bin/steps/cryptography b/bin/steps/cryptography index 06afa5b9..95af4568 100755 --- a/bin/steps/cryptography +++ b/bin/steps/cryptography @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This script serves as the Cryptography build step of the +# This script serves as the cffi build step of the # [**Python Buildpack**](https://github.com/heroku/heroku-buildpack-python) # compiler. # @@ -9,6 +9,11 @@ # # This script is invoked by [`bin/compile`](/). +if [[ "$STACK" == "heroku-16" ]]; then + # libffi is pre-installed in the stack image so there is no need to vendor it. + return 0 +fi + # The location of the pre-compiled libffi binary. VENDORED_LIBFFI="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libffi.tar.gz" diff --git a/bin/steps/pylibmc b/bin/steps/pylibmc index 2ebba64e..698d6684 100755 --- a/bin/steps/pylibmc +++ b/bin/steps/pylibmc @@ -9,6 +9,11 @@ # # This script is invoked by [`bin/compile`](/). +if [[ "$STACK" == "heroku-16" ]]; then + # libmemcached is pre-installed in the stack image so there is no need to vendor it. + return 0 +fi + # The location of the pre-compiled libmemcached binary. VENDORED_MEMCACHED="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libmemcache.tar.gz" @@ -16,7 +21,6 @@ VENDORED_MEMCACHED="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor # shellcheck source=bin/utils source "$BIN_DIR/utils" - # If pylibmc exists within requirements, use vendored libmemcached. if (pip-grep -s requirements.txt pylibmc &> /dev/null) then diff --git a/test/fixtures/cffi/requirements.txt b/test/fixtures/cffi/requirements.txt new file mode 100644 index 00000000..6a88e4b7 --- /dev/null +++ b/test/fixtures/cffi/requirements.txt @@ -0,0 +1 @@ +cffi diff --git a/test/run b/test/run index 3064ef91..faec5755 100755 --- a/test/run +++ b/test/run @@ -47,6 +47,12 @@ testPsycopg2() { assertCapturedSuccess } +testCffi() { + compile "cffi" + assertCaptured "cffi" + assertCapturedSuccess +} + testPylibmc() { compile "pylibmc" assertCaptured "pylibmc" -- GitLab