Skip to content
Snippets Groups Projects
Commit e15f6894 authored by Jose Diaz-Gonzalez's avatar Jose Diaz-Gonzalez Committed by Kenneth Reitz
Browse files

feat: allow stack url overrides using BUILDPACK_VENDOR_URL env var (#643)

This is useful if you'd like to customize python binaries without forking the entire buildpack.

Similar functionality was implemented in https://github.com/heroku/heroku-buildpack-ruby/pull/238
parent 9468ec26
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,12 @@ ENV_DIR=$3 ...@@ -33,6 +33,12 @@ ENV_DIR=$3
export BUILD_DIR CACHE_DIR ENV_DIR export BUILD_DIR CACHE_DIR ENV_DIR
VENDOR_URL="https://lang-python.s3.amazonaws.com/$STACK"
if [[ -n ${BUILDPACK_VENDOR_URL:-} ]]; then
VENDOR_URL="$BUILDPACK_VENDOR_URL"
fi
export VENDOR_URL
# Python defaults # Python defaults
DEFAULT_PYTHON_VERSION="python-3.6.4" DEFAULT_PYTHON_VERSION="python-3.6.4"
LATEST_3="python-3.6.4" LATEST_3="python-3.6.4"
......
...@@ -15,7 +15,7 @@ if [[ "$STACK" == "heroku-16" ]]; then ...@@ -15,7 +15,7 @@ if [[ "$STACK" == "heroku-16" ]]; then
fi fi
# The location of the pre-compiled libffi binary. # The location of the pre-compiled libffi binary.
VENDORED_LIBFFI="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libffi.tar.gz" VENDORED_LIBFFI="${VENDOR_URL}/libraries/vendor/libffi.tar.gz"
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH" PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# This script is invoked by [`bin/compile`](/). # This script is invoked by [`bin/compile`](/).
# The location of the pre-compiled cryptography binary. # The location of the pre-compiled cryptography binary.
VENDORED_GDAL="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/gdal.tar.gz" VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH" PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
# This script is invoked by [`bin/compile`](/). # This script is invoked by [`bin/compile`](/).
# The location of the pre-compiled cryptography binary. # The location of the pre-compiled cryptography binary.
VENDORED_GDAL="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/gdal.tar.gz" VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
VENDORED_GEOS="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/geos.tar.gz" VENDORED_GEOS="${VENDOR_URL}/libraries/vendor/geos.tar.gz"
VENDORED_PROJ="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/proj.tar.gz" VENDORED_PROJ="${VENDOR_URL}/libraries/vendor/proj.tar.gz"
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH" PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
......
...@@ -15,7 +15,7 @@ if [[ "$STACK" == "heroku-16" ]]; then ...@@ -15,7 +15,7 @@ if [[ "$STACK" == "heroku-16" ]]; then
fi fi
# The location of the pre-compiled libmemcached binary. # The location of the pre-compiled libmemcached binary.
VENDORED_MEMCACHED="https://lang-python.s3.amazonaws.com/$STACK/libraries/vendor/libmemcache.tar.gz" VENDORED_MEMCACHED="${VENDOR_URL}/libraries/vendor/libmemcache.tar.gz"
# Syntax sugar. # Syntax sugar.
# shellcheck source=bin/utils # shellcheck source=bin/utils
......
...@@ -4,6 +4,9 @@ set +e ...@@ -4,6 +4,9 @@ set +e
runtime-fixer runtime.txt runtime-fixer runtime.txt
PYTHON_VERSION=$(cat runtime.txt) PYTHON_VERSION=$(cat runtime.txt)
# The location of the pre-compiled python binary.
VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz"
if [[ $PYTHON_VERSION =~ ^python-2 ]]; then if [[ $PYTHON_VERSION =~ ^python-2 ]]; then
if [[ "$PYTHON_VERSION" != "$LATEST_2" ]]; then if [[ "$PYTHON_VERSION" != "$LATEST_2" ]]; then
puts-warn "The latest version of Python 2 is $LATEST_2 (you are using $PYTHON_VERSION, which is unsupported)." puts-warn "The latest version of Python 2 is $LATEST_2 (you are using $PYTHON_VERSION, which is unsupported)."
...@@ -41,7 +44,7 @@ if [ ! "$SKIP_INSTALL" ]; then ...@@ -41,7 +44,7 @@ if [ ! "$SKIP_INSTALL" ]; then
mcount "version.python.$PYTHON_VERSION" mcount "version.python.$PYTHON_VERSION"
if ! curl "https://lang-python.s3.amazonaws.com/$STACK/runtimes/$PYTHON_VERSION.tar.gz" -s | tar zxv -C .heroku/python &> /dev/null; then if ! curl "${VENDORED_PYTHON}" -s | tar zxv -C .heroku/python &> /dev/null; then
puts-warn "Requested runtime ($PYTHON_VERSION) is not available for this stack ($STACK)." puts-warn "Requested runtime ($PYTHON_VERSION) is not available for this stack ($STACK)."
puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support" puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support"
exit 1 exit 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment