mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
b74a41395e
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@.
56 lines
2.1 KiB
Bash
Executable File
56 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This script serves as the GDAL build step of the
|
|
# [**Python Buildpack**](https://github.com/heroku/heroku-buildpack-python)
|
|
# compiler.
|
|
#
|
|
# A [buildpack](https://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_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"
|
|
|
|
# Syntax sugar.
|
|
# shellcheck source=bin/utils
|
|
source "$BIN_DIR/utils"
|
|
|
|
# If GDAL exists within requirements, use vendored gdal.
|
|
if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
|
|
mcount "buildvar.BUILD_WITH_GEO_LIBRARIES"
|
|
|
|
puts-warn "The GDAL, GEOS and PROJ binaries and BUILD_WITH_GEO_LIBRARIES functonality are now deprecated."
|
|
puts-warn "An alternative buildpack to enable GDAL, GEOS and PROJ use is available here - https://github.com/heroku/heroku-geo-buildpack"
|
|
|
|
if [ ! -f ".heroku/vendor/bin/proj" ]; then
|
|
echo "-----> Bootstrapping gdal, geos, proj."
|
|
mkdir -p .heroku/vendor
|
|
# Download and extract cryptography into target vendor directory.
|
|
curl "$VENDORED_GDAL" -s | tar zxv -C .heroku/vendor &> /dev/null
|
|
curl "$VENDORED_GEOS" -s | tar zxv -C .heroku/vendor &> /dev/null
|
|
curl "$VENDORED_PROJ" -s | tar zxv -C .heroku/vendor &> /dev/null
|
|
|
|
mcount "steps.vendor.geo_libs"
|
|
# Copy libjasper from build image to slug.
|
|
if [[ "$STACK" == "heroku-16" ]]; then
|
|
cp /usr/lib/x86_64-linux-gnu/libjasper.so* ".heroku/vendor/lib/."
|
|
mcount "steps.vendor.libjasper"
|
|
fi
|
|
|
|
fi
|
|
|
|
GDAL=$(pwd)/vendor
|
|
export GDAL
|
|
# set path for post_compile hooks
|
|
export GDAL_LIBRARY_PATH="$BUILD_DIR/.heroku/vendor/lib/libgdal.so"
|
|
export GEOS_LIBRARY_PATH="$BUILD_DIR/.heroku/vendor/lib/libgeos_c.so"
|
|
# set path for runtime environmeht
|
|
set_env GDAL_LIBRARY_PATH "/app/.heroku/vendor/lib/libgdal.so"
|
|
set_env GEOS_LIBRARY_PATH "/app/.heroku/vendor/lib/libgeos_c.so"
|
|
fi
|