Skip to content
Snippets Groups Projects
Commit 0e11dbad authored by Kenneth Reitz's avatar Kenneth Reitz
Browse files

bpwatch

parent 96cf5718
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ LEGACY_TRIGGER="lib/python2.7" ...@@ -26,6 +26,7 @@ LEGACY_TRIGGER="lib/python2.7"
PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh" PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh"
DEFAULT_PYTHON_VERSION="python-2.7.8" DEFAULT_PYTHON_VERSION="python-2.7.8"
DEFAULT_PYTHON_STACK="cedar"
PYTHON_EXE="/app/.heroku/python/bin/python" PYTHON_EXE="/app/.heroku/python/bin/python"
PIP_VERSION="1.5.6" PIP_VERSION="1.5.6"
SETUPTOOLS_VERSION="3.6" SETUPTOOLS_VERSION="3.6"
...@@ -43,11 +44,11 @@ BUILDPACK_VERSION=v28 ...@@ -43,11 +44,11 @@ BUILDPACK_VERSION=v28
# Sanitizing environment variables. # Sanitizing environment variables.
unset GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH unset GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH
# bpwatch init $LOGPLEX_KEY bpwatch init $LOGPLEX_KEY
# bpwatch build python $BUILDPACK_VERSION $REQUEST_ID bpwatch build python $BUILDPACK_VERSION $REQUEST_ID
TMP_APP_DIR=$CACHE_DIR/tmp_app_dir TMP_APP_DIR=$CACHE_DIR/tmp_app_dir
# bpwatch start compile bpwatch start compile
# We'll need to send these statics to other scripts we `source`. # We'll need to send these statics to other scripts we `source`.
...@@ -61,19 +62,19 @@ APP_DIR='/app' ...@@ -61,19 +62,19 @@ APP_DIR='/app'
TMP_APP_DIR=$CACHE_DIR/tmp_app_dir TMP_APP_DIR=$CACHE_DIR/tmp_app_dir
# Copy Anvil app dir to temporary storage... # Copy Anvil app dir to temporary storage...
# bpwatch start anvil_appdir_stage bpwatch start anvil_appdir_stage
if [ "$SLUG_ID" ]; then if [ "$SLUG_ID" ]; then
mkdir -p $TMP_APP_DIR mkdir -p $TMP_APP_DIR
deep-mv $APP_DIR $TMP_APP_DIR deep-mv $APP_DIR $TMP_APP_DIR
else else
deep-rm $APP_DIR deep-rm $APP_DIR
fi fi
# bpwatch stop anvil_appdir_stage bpwatch stop anvil_appdir_stage
# Copy Application code in. # Copy Application code in.
# bpwatch start appdir_stage bpwatch start appdir_stage
deep-mv $BUILD_DIR $APP_DIR deep-mv $BUILD_DIR $APP_DIR
# bpwatch stop appdir_stage bpwatch stop appdir_stage
# Set new context. # Set new context.
ORIG_BUILD_DIR=$BUILD_DIR ORIG_BUILD_DIR=$BUILD_DIR
...@@ -93,9 +94,9 @@ export PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkg-config:$BUILD_DIR/.heroku/ven ...@@ -93,9 +94,9 @@ export PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkg-config:$BUILD_DIR/.heroku/ven
cd $BUILD_DIR cd $BUILD_DIR
# Experimental pre_compile hook. # Experimental pre_compile hook.
# bpwatch start pre_compile bpwatch start pre_compile
source $BIN_DIR/steps/hooks/pre_compile source $BIN_DIR/steps/hooks/pre_compile
# bpwatch stop pre_compile bpwatch stop pre_compile
# If no requirements given, assume `setup.py develop`. # If no requirements given, assume `setup.py develop`.
if [ ! -f requirements.txt ]; then if [ ! -f requirements.txt ]; then
...@@ -104,9 +105,9 @@ if [ ! -f requirements.txt ]; then ...@@ -104,9 +105,9 @@ if [ ! -f requirements.txt ]; then
fi fi
# Sticky runtimes. # Sticky runtimes.
# if [ -f $CACHE_DIR/.heroku/python-version ]; then if [ -f $CACHE_DIR/.heroku/python-version ]; then
# DEFAULT_PYTHON_VERSION=$(cat $CACHE_DIR/.heroku/python-version) DEFAULT_PYTHON_VERSION=$(cat $CACHE_DIR/.heroku/python-version)
# fi fi
# If no runtime given, assume default version. # If no runtime given, assume default version.
if [ ! -f runtime.txt ]; then if [ ! -f runtime.txt ]; then
...@@ -117,17 +118,17 @@ fi ...@@ -117,17 +118,17 @@ fi
mkdir -p $CACHE_DIR mkdir -p $CACHE_DIR
# Purge "old-style" virtualenvs. # Purge "old-style" virtualenvs.
# bpwatch start clear_old_venvs 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/$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/$VIRTUALENV_LOC ] && rm -fr $CACHE_DIR/.heroku/venv $CACHE_DIR/.heroku/src
# bpwatch stop clear_old_venvs bpwatch stop clear_old_venvs
# Restore old artifacts from the cache. # Restore old artifacts from the cache.
# bpwatch start restore_cache bpwatch start restore_cache
for dir in $CACHED_DIRS; do for dir in $CACHED_DIRS; do
cp -R $CACHE_DIR/$dir . &> /dev/null || true cp -R $CACHE_DIR/$dir . &> /dev/null || true
done done
# bpwatch stop restore_cache bpwatch stop restore_cache
set +e set +e
# Create set-aside `.heroku` folder. # Create set-aside `.heroku` folder.
...@@ -142,10 +143,10 @@ PYTHON_VERSION=$(cat runtime.txt) ...@@ -142,10 +143,10 @@ PYTHON_VERSION=$(cat runtime.txt)
# Install Python. # Install Python.
if [ -f .heroku/python-version ]; then if [ -f .heroku/python-version ]; then
if [ ! $(cat .heroku/python-version) = $PYTHON_VERSION ]; then if [ ! $(cat .heroku/python-version) = $PYTHON_VERSION ]; then
# bpwatch start uninstall_python bpwatch start uninstall_python
puts-step "Found $(cat .heroku/python-version), removing." puts-step "Found $(cat .heroku/python-version), removing."
rm -fr .heroku/python rm -fr .heroku/python
# bpwatch stop uninstall_python bpwatch stop uninstall_python
else else
SKIP_INSTALL=1 SKIP_INSTALL=1
fi fi
...@@ -153,7 +154,7 @@ fi ...@@ -153,7 +154,7 @@ fi
if [ ! "$SKIP_INSTALL" ]; then if [ ! "$SKIP_INSTALL" ]; then
# bpwatch start install_python bpwatch start install_python
puts-step "Preparing Python runtime ($PYTHON_VERSION)" puts-step "Preparing Python runtime ($PYTHON_VERSION)"
# Prepare destination directory. # Prepare destination directory.
...@@ -166,7 +167,7 @@ if [ ! "$SKIP_INSTALL" ]; then ...@@ -166,7 +167,7 @@ if [ ! "$SKIP_INSTALL" ]; then
exit 1 exit 1
fi fi
# bpwatch stop install_python bpwatch stop install_python
# Record for future reference. # Record for future reference.
echo $PYTHON_VERSION > .heroku/python-version echo $PYTHON_VERSION > .heroku/python-version
...@@ -181,9 +182,9 @@ fi ...@@ -181,9 +182,9 @@ fi
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
WORKING_DIR=$(pwd) WORKING_DIR=$(pwd)
# bpwatch start prepare_environment bpwatch start prepare_environment
# bpwatch start install_setuptools bpwatch start install_setuptools
# Prepare it for the real world # Prepare it for the real world
puts-step "Installing Setuptools ($SETUPTOOLS_VERSION)" puts-step "Installing Setuptools ($SETUPTOOLS_VERSION)"
cd $ROOT_DIR/vendor/ cd $ROOT_DIR/vendor/
...@@ -191,9 +192,9 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then ...@@ -191,9 +192,9 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
cd $ROOT_DIR/vendor/setuptools-$SETUPTOOLS_VERSION/ cd $ROOT_DIR/vendor/setuptools-$SETUPTOOLS_VERSION/
python setup.py install &> /dev/null python setup.py install &> /dev/null
cd $WORKING_DIR cd $WORKING_DIR
# bpwatch stop install_setuptoools bpwatch stop install_setuptoools
# bpwatch start install_pip bpwatch start install_pip
puts-step "Installing Pip ($PIP_VERSION)" puts-step "Installing Pip ($PIP_VERSION)"
cd $ROOT_DIR/vendor/ cd $ROOT_DIR/vendor/
...@@ -202,8 +203,8 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then ...@@ -202,8 +203,8 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
python setup.py install &> /dev/null python setup.py install &> /dev/null
cd $WORKING_DIR cd $WORKING_DIR
# bpwatch stop install_pip bpwatch stop install_pip
# bpwatch stop prepare_environment bpwatch stop prepare_environment
fi fi
set -e set -e
...@@ -211,9 +212,9 @@ hash -r ...@@ -211,9 +212,9 @@ hash -r
# Pylibmc support. # Pylibmc support.
# See [`bin/steps/pylibmc`](pylibmc.html). # See [`bin/steps/pylibmc`](pylibmc.html).
# bpwatch start pylibmc_install bpwatch start pylibmc_install
source $BIN_DIR/steps/pylibmc source $BIN_DIR/steps/pylibmc
# bpwatch stop pylibmc_install bpwatch stop pylibmc_install
# DEBUGGING # DEBUGGING
...@@ -224,27 +225,27 @@ echo $STACK ...@@ -224,27 +225,27 @@ echo $STACK
# Install Mercurial if it appears to be required. # Install Mercurial if it appears to be required.
if (grep -Fiq "hg+" requirements.txt) then if (grep -Fiq "hg+" requirements.txt) then
# bpwatch start mercurial_install bpwatch start mercurial_install
/app/.heroku/python/bin/pip install mercurial | cleanup | indent /app/.heroku/python/bin/pip install mercurial | cleanup | indent
# bpwatch stop mercurial_install bpwatch stop mercurial_install
fi fi
# Install dependencies with Pip. # Install dependencies with Pip.
puts-step "Installing dependencies using Pip ($PIP_VERSION)" puts-step "Installing dependencies using Pip ($PIP_VERSION)"
# [ ! "$FRESH_PYTHON" ] && bpwatch start pip_install [ ! "$FRESH_PYTHON" ] && bpwatch start pip_install
# [ "$FRESH_PYTHON" ] && bpwatch start pip_install_first [ "$FRESH_PYTHON" ] && bpwatch start pip_install_first
/app/.heroku/python/bin/pip install -r requirements.txt --exists-action=w --src=./.heroku/src --allow-all-external | cleanup | indent /app/.heroku/python/bin/pip install -r requirements.txt --exists-action=w --src=./.heroku/src --allow-all-external | cleanup | indent
# [ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install [ ! "$FRESH_PYTHON" ] && bpwatch stop pip_install
# [ "$FRESH_PYTHON" ] && bpwatch stop pip_install_first [ "$FRESH_PYTHON" ] && bpwatch stop pip_install_first
# Django collectstatic support. # Django collectstatic support.
# bpwatch start collectstatic bpwatch start collectstatic
sub-env $BIN_DIR/steps/collectstatic sub-env $BIN_DIR/steps/collectstatic
# bpwatch stop collectstatic bpwatch stop collectstatic
# ### Finalize # ### Finalize
# #
...@@ -261,27 +262,27 @@ set-default-env PYTHONPATH /app/ ...@@ -261,27 +262,27 @@ set-default-env PYTHONPATH /app/
# Experimental post_compile hook. # Experimental post_compile hook.
# bpwatch start post_compile bpwatch start post_compile
source $BIN_DIR/steps/hooks/post_compile source $BIN_DIR/steps/hooks/post_compile
# bpwatch stop post_compile bpwatch stop post_compile
# Store new artifacts in cache. # Store new artifacts in cache.
# bpwatch start dump_cache bpwatch start dump_cache
for dir in $CACHED_DIRS; do for dir in $CACHED_DIRS; do
rm -rf $CACHE_DIR/$dir rm -rf $CACHE_DIR/$dir
cp -R $dir $CACHE_DIR/ cp -R $dir $CACHE_DIR/
done done
# bpwatch stop dump_cache bpwatch stop dump_cache
# ### Fin. # ### Fin.
# bpwatch start appdir_commit bpwatch start appdir_commit
deep-mv $BUILD_DIR $ORIG_BUILD_DIR deep-mv $BUILD_DIR $ORIG_BUILD_DIR
# bpwatch stop appdir_commit bpwatch stop appdir_commit
# bpwatch start anvil_appdir_commit bpwatch start anvil_appdir_commit
if [ "$SLUG_ID" ]; then if [ "$SLUG_ID" ]; then
deep-mv $TMP_APP_DIR $APP_DIR deep-mv $TMP_APP_DIR $APP_DIR
fi fi
# bpwatch stop anvil_appdir_commit bpwatch stop anvil_appdir_commit
# bpwatch stop compile bpwatch stop compile
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment