Skip to content

Refactor S3 asset URL handling #1085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

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

## v181 (2020-09-29)

Expand Down
16 changes: 7 additions & 9 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ ENV_DIR=$3
# Export Path variables, for use in sub-scripts.
export BUILD_DIR CACHE_DIR ENV_DIR

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

# Default Python Versions
# shellcheck source=bin/default_pythons
Expand Down
2 changes: 1 addition & 1 deletion bin/steps/gdal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# This script is invoked by [`bin/compile`](/).

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

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

Expand Down
6 changes: 3 additions & 3 deletions bin/steps/geo-libs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# This script is invoked by [`bin/compile`](/).

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

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

Expand Down
2 changes: 1 addition & 1 deletion bin/steps/pylibmc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [[ "$STACK" != "cedar-14" ]]; then
fi

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

# Syntax sugar.
# shellcheck source=bin/utils
Expand Down
4 changes: 2 additions & 2 deletions bin/steps/python
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runtime-fixer runtime.txt
PYTHON_VERSION=$(cat runtime.txt)

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

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

if ! curl -sSf "${PIP_WHEEL_URL}" -o "$PIP_WHEEL"; then
Expand Down
2 changes: 1 addition & 1 deletion test/run-features
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ testHooks() {
PROFILE_PATH
PWD
PYTHONUNBUFFERED
S3_BASE_URL
SHLVL
SOME_APP_CONFIG_VAR
STACK
VENDOR_URL
)
if [[ "${STACK}" == "cedar-14" || "${STACK}" == "heroku-16" ]]; then
# Remove "OLDPWD" from expected_env_vars since for bash <4.4 it's not exported to subshells:
Expand Down