Skip to content

Commit b74a413

Browse files
authored
Refactor S3 asset URL handling (#1085)
Previously the buildpack's S3 bucket was defined in two places - once in `VENDOR_URL` and again during the pip installation step. This duplication was necessary since `VENDOR_URL` also contained the stack's name, whereas the pip use-case used a non-stack-specific S3 key prefix. In order to: * reduce this duplication * simplify this buildpack's S3 bucket migration (where we'll soon be needing the vary the bucket name and wouldn't want to have to duplicate that logic in multiple places) * allow overriding of the URL for the pip use-case ...the `VENDOR_URL` variable has been replaced with `S3_BASE_URL` which no longer contains the stack name. The user-configurable override has similarly been renamed from `BUILDPACK_VENDOR_URL` to `BUILDPACK_S3_BASE_URL`. Note: As before, this override cannot be set via standard app variables (see #989). The unused `USE_STAGING_BINARIES` environment variable has been removed, since it's a leftover from the project to stand up a staging S3 bucket. It's redundant given the `BUILDPACK_S3_BASE_URL` variable. Closes @W-8142401@.
1 parent c550143 commit b74a413

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Replace `BUILDPACK_VENDOR_URL` and `USE_STAGING_BINARIES` with `BUILDPACK_S3_BASE_URL` (#1085).
56

67
## v181 (2020-09-29)
78

bin/compile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ ENV_DIR=$3
3737
# Export Path variables, for use in sub-scripts.
3838
export BUILD_DIR CACHE_DIR ENV_DIR
3939

40-
# Set the Buildpack's internet target for downloading Python distributions.
41-
# The user can provide BUILDPACK_VENDOR_URL to specify a custom target.
40+
# Set the base URL for downloading buildpack assets like Python runtimes.
41+
# The user can provide BUILDPACK_S3_BASE_URL to specify a custom target.
4242
# Note: this is designed for non-Heroku use, as it does not use the user-provided
4343
# environment variable mechanism (the ENV_DIR).
44-
VENDOR_URL="https://lang-python.s3.amazonaws.com/$STACK"
45-
if [[ -n ${BUILDPACK_VENDOR_URL:-} ]]; then
46-
VENDOR_URL="$BUILDPACK_VENDOR_URL"
47-
elif [[ -n ${USE_STAGING_BINARIES} ]]; then
48-
VENDOR_URL="$USE_STAGING_BINARIES/$STACK"
49-
fi
50-
export VENDOR_URL
44+
DEFAULT_S3_BASE_URL='https://lang-python.s3.amazonaws.com'
45+
S3_BASE_URL="${BUILDPACK_S3_BASE_URL:-${DEFAULT_S3_BASE_URL}}"
46+
# This has to be exported since it's used by the geo-libs step which is run in a subshell.
47+
# TODO: Stop exporting once the geo-libs step is removed or no longer uses `sub_env`.
48+
export S3_BASE_URL
5149

5250
# Default Python Versions
5351
# shellcheck source=bin/default_pythons

bin/steps/gdal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# This script is invoked by [`bin/compile`](/).
1111

1212
# The location of the pre-compiled cryptography binary.
13-
VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
13+
VENDORED_GDAL="${S3_BASE_URL}/${STACK}/libraries/vendor/gdal.tar.gz"
1414

1515
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
1616

bin/steps/geo-libs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# This script is invoked by [`bin/compile`](/).
1111

1212
# The location of the pre-compiled cryptography binary.
13-
VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
14-
VENDORED_GEOS="${VENDOR_URL}/libraries/vendor/geos.tar.gz"
15-
VENDORED_PROJ="${VENDOR_URL}/libraries/vendor/proj.tar.gz"
13+
VENDORED_GDAL="${S3_BASE_URL}/${STACK}/libraries/vendor/gdal.tar.gz"
14+
VENDORED_GEOS="${S3_BASE_URL}/${STACK}/libraries/vendor/geos.tar.gz"
15+
VENDORED_PROJ="${S3_BASE_URL}/${STACK}/libraries/vendor/proj.tar.gz"
1616

1717
PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
1818

bin/steps/pylibmc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [[ "$STACK" != "cedar-14" ]]; then
1515
fi
1616

1717
# The location of the pre-compiled libmemcached binary.
18-
VENDORED_MEMCACHED="${VENDOR_URL}/libraries/vendor/libmemcache.tar.gz"
18+
VENDORED_MEMCACHED="${S3_BASE_URL}/${STACK}/libraries/vendor/libmemcache.tar.gz"
1919

2020
# Syntax sugar.
2121
# shellcheck source=bin/utils

bin/steps/python

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runtime-fixer runtime.txt
55
PYTHON_VERSION=$(cat runtime.txt)
66

77
# The location of the pre-compiled python binary.
8-
VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz"
8+
VENDORED_PYTHON="${S3_BASE_URL}/${STACK}/runtimes/${PYTHON_VERSION}.tar.gz"
99

1010
SECURITY_UPDATE="Python has released a security update! Please consider upgrading to"
1111
SECURITY_UPDATE_PYPY="The PyPy project has released a security update! Please consider upgrading to"
@@ -160,7 +160,7 @@ fi
160160
# Instead, we use the pip wheel to install itself, using the method described here:
161161
# https://github.com/pypa/pip/issues/2351#issuecomment-69994524
162162
PIP_WHEEL_FILENAME="pip-${PIP_VERSION}-py2.py3-none-any.whl"
163-
PIP_WHEEL_URL="https://lang-python.s3.amazonaws.com/common/${PIP_WHEEL_FILENAME}"
163+
PIP_WHEEL_URL="${S3_BASE_URL}/common/${PIP_WHEEL_FILENAME}"
164164
PIP_WHEEL="${TMPDIR:-/tmp}/${PIP_WHEEL_FILENAME}"
165165

166166
if ! curl -sSf "${PIP_WHEEL_URL}" -o "$PIP_WHEEL"; then

test/run-features

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ testHooks() {
113113
PROFILE_PATH
114114
PWD
115115
PYTHONUNBUFFERED
116+
S3_BASE_URL
116117
SHLVL
117118
SOME_APP_CONFIG_VAR
118119
STACK
119-
VENDOR_URL
120120
)
121121
if [[ "${STACK}" == "cedar-14" || "${STACK}" == "heroku-16" ]]; then
122122
# Remove "OLDPWD" from expected_env_vars since for bash <4.4 it's not exported to subshells:

0 commit comments

Comments
 (0)