mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b7edad8a2 | |||
| 02787ac910 | |||
| 31e65dc58b | |||
| 9a227e6c73 | |||
| ddc9c24d34 | |||
| 42488a2be7 | |||
| 839486c25b | |||
| 5d56200179 |
+49
-45
@@ -30,16 +30,17 @@ PYTHON_EXE="/app/.heroku/python/bin/python"
|
||||
PIP_VERSION="1.3.1"
|
||||
DISTRIBUTE_VERSION="0.6.36"
|
||||
|
||||
# Setup bpwatch
|
||||
export PATH=$PATH:$ROOT_DIR/vendor/bpwatch
|
||||
|
||||
LOGPLEX_KEY="t.b396af7f-ad75-4643-8b9e-ebb288acc624"
|
||||
BUILDPACK_VERSION=HEAD
|
||||
|
||||
export BPWATCH_STORE_PATH=$CACHE_DIR/bpwatch.json
|
||||
BUILDPACK_VERSION=v25
|
||||
|
||||
# Support Anvil Build_IDs
|
||||
[ ! "$REQUEST_ID" ] && REQUEST_ID=$SLUG_ID
|
||||
|
||||
|
||||
# Sanitizing environment variables.
|
||||
unset GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH
|
||||
|
||||
bpwatch init $LOGPLEX_KEY
|
||||
bpwatch build python $BUILDPACK_VERSION $REQUEST_ID
|
||||
@@ -48,9 +49,6 @@ TMP_APP_DIR=$CACHE_DIR/tmp_app_dir
|
||||
bpwatch start compile
|
||||
|
||||
|
||||
# Sanitizing environment variables.
|
||||
unset GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH
|
||||
|
||||
# We'll need to send these statics to other scripts we `source`.
|
||||
export BUILD_DIR CACHE_DIR BIN_DIR PROFILE_PATH
|
||||
|
||||
@@ -63,13 +61,17 @@ TMP_APP_DIR=$CACHE_DIR/tmp_app_dir
|
||||
|
||||
# Copy Anvil app dir to temporary storage...
|
||||
bpwatch start anvil_appdir_stage
|
||||
mkdir -p $TMP_APP_DIR
|
||||
deep-mv $APP_DIR $TMP_APP_DIR
|
||||
if [ "$SLUG_ID" ]; then
|
||||
mkdir -p $TMP_APP_DIR
|
||||
deep-mv $APP_DIR $TMP_APP_DIR
|
||||
else
|
||||
deep-rm $APP_DIR
|
||||
fi
|
||||
bpwatch stop anvil_appdir_stage
|
||||
|
||||
# Copy Application code in.
|
||||
bpwatch start appdir_stage
|
||||
deep-mv $BUILD_DIR $APP_DIR
|
||||
deep-mv $BUILD_DIR $APP_DIR
|
||||
bpwatch stop appdir_stage
|
||||
|
||||
# Set new context.
|
||||
@@ -88,7 +90,7 @@ cd $BUILD_DIR
|
||||
|
||||
# Experimental pre_compile hook.
|
||||
bpwatch start pre_compile
|
||||
source $BIN_DIR/steps/hooks/pre_compile
|
||||
source $BIN_DIR/steps/hooks/pre_compile
|
||||
bpwatch stop pre_compile
|
||||
|
||||
# If no requirements given, assume `setup.py develop`.
|
||||
@@ -108,15 +110,15 @@ mkdir -p $CACHE_DIR
|
||||
|
||||
# Purge "old-style" virtualenvs.
|
||||
bpwatch start clear_old_venvs
|
||||
[ -d $CACHE_DIR/$LEGACY_TRIGGER ] && rm -fr $CACHE_DIR/.heroku/bin $CACHE_DIR/.heroku/lib $CACHE_DIR/.heroku/include
|
||||
[ -d $CACHE_DIR/$VIRTUALENV_LOC ] && rm -fr $CACHE_DIR/.heroku/venv $CACHE_DIR/.heroku/src
|
||||
[ -d $CACHE_DIR/$LEGACY_TRIGGER ] && rm -fr $CACHE_DIR/.heroku/bin $CACHE_DIR/.heroku/lib $CACHE_DIR/.heroku/include
|
||||
[ -d $CACHE_DIR/$VIRTUALENV_LOC ] && rm -fr $CACHE_DIR/.heroku/venv $CACHE_DIR/.heroku/src
|
||||
bpwatch stop clear_old_venvs
|
||||
|
||||
# Restore old artifacts from the cache.
|
||||
bpwatch start restore_cache
|
||||
for dir in $CACHED_DIRS; do
|
||||
cp -R $CACHE_DIR/$dir . &> /dev/null || true
|
||||
done
|
||||
for dir in $CACHED_DIRS; do
|
||||
cp -R $CACHE_DIR/$dir . &> /dev/null || true
|
||||
done
|
||||
bpwatch stop restore_cache
|
||||
|
||||
set +e
|
||||
@@ -133,8 +135,8 @@ PYTHON_VERSION=$(cat runtime.txt)
|
||||
if [ -f .heroku/python-version ]; then
|
||||
if [ ! $(cat .heroku/python-version) = $PYTHON_VERSION ]; then
|
||||
bpwatch start uninstall_python
|
||||
puts-step "Found $(cat .heroku/python-version), removing."
|
||||
rm -fr .heroku/python
|
||||
puts-step "Found $(cat .heroku/python-version), removing."
|
||||
rm -fr .heroku/python
|
||||
bpwatch stop uninstall_python
|
||||
else
|
||||
SKIP_INSTALL=1
|
||||
@@ -144,14 +146,14 @@ fi
|
||||
|
||||
if [ ! "$SKIP_INSTALL" ]; then
|
||||
bpwatch start install_python
|
||||
puts-step "Preparing Python runtime ($PYTHON_VERSION)"
|
||||
curl http://envy-versions.s3.amazonaws.com/$PYTHON_VERSION.tar.bz2 -s | tar jx &> /dev/null
|
||||
if [[ $? != 0 ]] ; then
|
||||
puts-warn "Requested runtime ($PYTHON_VERSION) was not found."
|
||||
puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support"
|
||||
exit 1
|
||||
fi
|
||||
mv python .heroku/python
|
||||
puts-step "Preparing Python runtime ($PYTHON_VERSION)"
|
||||
curl http://envy-versions.s3.amazonaws.com/$PYTHON_VERSION.tar.bz2 -s | tar jx &> /dev/null
|
||||
if [[ $? != 0 ]] ; then
|
||||
puts-warn "Requested runtime ($PYTHON_VERSION) was not found."
|
||||
puts-warn "Aborting. More info: https://devcenter.heroku.com/articles/python-support"
|
||||
exit 1
|
||||
fi
|
||||
mv python .heroku/python
|
||||
bpwatch stop install_python
|
||||
|
||||
# Record for future reference.
|
||||
@@ -170,18 +172,18 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
|
||||
bpwatch start prepare_environment
|
||||
|
||||
bpwatch start install_distribute
|
||||
# Prepare it for the real world
|
||||
puts-step "Installing Distribute ($DISTRIBUTE_VERSION)"
|
||||
cd $ROOT_DIR/vendor/distribute-$DISTRIBUTE_VERSION/
|
||||
python setup.py install &> /dev/null
|
||||
cd $WORKING_DIR
|
||||
# Prepare it for the real world
|
||||
puts-step "Installing Distribute ($DISTRIBUTE_VERSION)"
|
||||
cd $ROOT_DIR/vendor/distribute-$DISTRIBUTE_VERSION/
|
||||
python setup.py install &> /dev/null
|
||||
cd $WORKING_DIR
|
||||
bpwatch stop install_distribute
|
||||
|
||||
bpwatch start install_pip
|
||||
puts-step "Installing Pip ($PIP_VERSION)"
|
||||
cd $ROOT_DIR/vendor/pip-$PIP_VERSION/
|
||||
python setup.py install &> /dev/null
|
||||
cd $WORKING_DIR
|
||||
puts-step "Installing Pip ($PIP_VERSION)"
|
||||
cd $ROOT_DIR/vendor/pip-$PIP_VERSION/
|
||||
python setup.py install &> /dev/null
|
||||
cd $WORKING_DIR
|
||||
|
||||
bpwatch stop install_pip
|
||||
bpwatch stop prepare_environment
|
||||
@@ -193,13 +195,13 @@ hash -r
|
||||
# Pylibmc support.
|
||||
# See [`bin/steps/pylibmc`](pylibmc.html).
|
||||
bpwatch start pylibmc_install
|
||||
source $BIN_DIR/steps/pylibmc
|
||||
source $BIN_DIR/steps/pylibmc
|
||||
bpwatch stop pylibmc_install
|
||||
|
||||
# Install Mercurial if it appears to be required.
|
||||
if (grep -Fiq "hg+" requirements.txt) then
|
||||
bpwatch start mercurial_install
|
||||
/app/.heroku/python/bin/pip install --use-mirrors mercurial | cleanup | indent
|
||||
/app/.heroku/python/bin/pip install --use-mirrors mercurial | cleanup | indent
|
||||
bpwatch stop mercurial_install
|
||||
fi
|
||||
|
||||
@@ -217,7 +219,7 @@ puts-step "Installing dependencies using Pip ($PIP_VERSION)"
|
||||
|
||||
# Django collectstatic support.
|
||||
bpwatch start collectstatic
|
||||
source $BIN_DIR/steps/collectstatic
|
||||
source $BIN_DIR/steps/collectstatic
|
||||
bpwatch stop collectstatic
|
||||
|
||||
# ### Finalize
|
||||
@@ -236,24 +238,26 @@ set-default-env PYTHONPATH /app/
|
||||
|
||||
# Experimental post_compile hook.
|
||||
bpwatch start post_compile
|
||||
source $BIN_DIR/steps/hooks/post_compile
|
||||
source $BIN_DIR/steps/hooks/post_compile
|
||||
bpwatch stop post_compile
|
||||
|
||||
# Store new artifacts in cache.
|
||||
bpwatch start dump_cache
|
||||
for dir in $CACHED_DIRS; do
|
||||
rm -rf $CACHE_DIR/$dir
|
||||
cp -R $dir $CACHE_DIR/
|
||||
done
|
||||
for dir in $CACHED_DIRS; do
|
||||
rm -rf $CACHE_DIR/$dir
|
||||
cp -R $dir $CACHE_DIR/
|
||||
done
|
||||
bpwatch stop dump_cache
|
||||
|
||||
# ### Fin.
|
||||
bpwatch start appdir_commit
|
||||
deep-mv $BUILD_DIR $ORIG_BUILD_DIR
|
||||
deep-mv $BUILD_DIR $ORIG_BUILD_DIR
|
||||
bpwatch stop appdir_commit
|
||||
|
||||
bpwatch start anvil_appdir_commit
|
||||
deep-mv $TMP_APP_DIR $APP_DIR
|
||||
if [ "$SLUG_ID" ]; then
|
||||
deep-mv $TMP_APP_DIR $APP_DIR
|
||||
fi
|
||||
bpwatch stop anvil_appdir_commit
|
||||
|
||||
bpwatch stop compile
|
||||
|
||||
@@ -52,3 +52,11 @@ function deep-mv (){
|
||||
rm -fr $1/!(tmp)
|
||||
find -H $1 -maxdepth 1 -name '.*' -a \( -type d -o -type f -o -type l \) -exec rm -fr '{}' \;
|
||||
}
|
||||
|
||||
# Does some serious deleting.
|
||||
function deep-rm (){
|
||||
rm -fr $1/!(tmp)
|
||||
find -H $1 -maxdepth 1 -name '.*' -a \( -type d -o -type f -o -type l \) -exec rm -fr '{}' \;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user