Files
heroku-buildpack-python/bin/steps/python
T
2017-03-10 12:37:11 -05:00

59 lines
1.6 KiB
Plaintext
Executable File

set +e
PYTHON_VERSION=$(cat runtime.txt)
# Install Python.
if [ -f .heroku/python-version ]; then
if [ ! $(cat .heroku/python-version) = $PYTHON_VERSION ]; then
puts-step "Found $(cat .heroku/python-version), removing"
rm -fr .heroku/python
else
SKIP_INSTALL=1
fi
fi
if [ ! $STACK = $CACHED_PYTHON_STACK ]; then
rm -fr .heroku/python .heroku/python-stack .heroku/vendor
unset SKIP_INSTALL
fi
if [ ! "$SKIP_INSTALL" ]; then
puts-step "Installing $PYTHON_VERSION"
# Prepare destination directory.
mkdir -p .heroku/python
curl https://lang-python.s3.amazonaws.com/$STACK/runtimes/$PYTHON_VERSION.tar.gz -s | tar zxv -C .heroku/python &> /dev/null
if [[ $? != 0 ]] ; then
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"
exit 1
fi
# Record for future reference.
echo $PYTHON_VERSION > .heroku/python-version
echo $STACK > .heroku/python-stack
FRESH_PYTHON=true
hash -r
fi
# If Pip isn't up to date:
if [ "$FRESH_PYTHON" ] || pip list -o --format=legacy --disable-pip-version-check | grep '^pip' 2>&1 /dev/null; then
# TODO: automatically detect pip is out of date with 'pip list -o --format=legacy --disable-pip-version-check | grep '^pip''
WORKING_DIR=$(pwd)
TMPTARDIR=$(mktemp -d)
trap "rm -rf $TMPTARDIR" RETURN
puts-step "Bootstrapping pip"
/app/.heroku/python/bin/python $ROOT_DIR/vendor/get-pip.py | indent
/app/.heroku/python/bin/pip install setuptools --upgrade &> /dev/null
fi
set -e
hash -r