gdal 1.06 KB
Newer Older
Kenneth Reitz's avatar
Kenneth Reitz committed
1 2 3 4 5 6
#!/usr/bin/env bash

# This script serves as the GDAL build step of the
# [**Python Buildpack**](https://github.com/heroku/heroku-buildpack-python)
# compiler.
#
7
# A [buildpack](https://devcenter.heroku.com/articles/buildpacks) is an
Kenneth Reitz's avatar
Kenneth Reitz committed
8 9 10 11 12
# adapter between a Python application and Heroku's runtime.
#
# This script is invoked by [`bin/compile`](/).

# The location of the pre-compiled cryptography binary.
13
VENDORED_GDAL="${VENDOR_URL}/libraries/vendor/gdal.tar.gz"
Kenneth Reitz's avatar
Kenneth Reitz committed
14

15
PKG_CONFIG_PATH="$BUILD_DIR/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
Kenneth Reitz's avatar
Kenneth Reitz committed
16 17

# Syntax sugar.
Kenneth Reitz's avatar
Kenneth Reitz committed
18 19
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
Kenneth Reitz's avatar
Kenneth Reitz committed
20 21

# If GDAL exists within requirements, use vendored gdal.
Kenneth Reitz's avatar
Kenneth Reitz committed
22
if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
Kenneth Reitz's avatar
Kenneth Reitz committed
23

24
  if [ ! -f ".heroku/vendor/bin/gdalserver" ]; then
Kenneth Reitz's avatar
Kenneth Reitz committed
25
    echo "-----> Noticed GDAL. Bootstrapping gdal."
Kenneth Reitz's avatar
Kenneth Reitz committed
26 27
    mkdir -p .heroku/vendor
    # Download and extract cryptography into target vendor directory.
Kenneth Reitz's avatar
Kenneth Reitz committed
28
    curl "$VENDORED_GDAL" -s | tar zxv -C .heroku/vendor &> /dev/null
29
    mcount "steps.vendor.gdal"
Kenneth Reitz's avatar
Kenneth Reitz committed
30
  fi
31

Kenneth Reitz's avatar
Kenneth Reitz committed
32 33
  GDAL=$(pwd)/vendor
  export GDAL
Kenneth Reitz's avatar
Kenneth Reitz committed
34
fi