Skip to content

Commit

Permalink
Support pre_compile and post_compile hooks when using Conda
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Pulver authored and cf-buildpacks-eng committed Apr 5, 2017
1 parent 0a3e5b0 commit 99b8cf2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions bin/compile
Expand Up @@ -22,6 +22,7 @@ BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
DEPS_DIR=${4:-}
export BUILD_DIR CACHE_DIR BIN_DIR

# CF Common
BUILDPACK_PATH=$ROOT_DIR
Expand All @@ -38,11 +39,26 @@ if [ -n "$DEPS_DIR" ]; then
fi
# END CF Common

# Syntax sugar.
source $BIN_DIR/utils

# Use miniconda if environment.yml exists and exit
if [ -f $BUILD_DIR/environment.yml ]; then
echo "----------------- USING CONDA BUILDPACK -----------------"

# Experimental pre_compile hook.
pushd $BUILD_DIR
source $BIN_DIR/steps/hooks/pre_compile
popd

$BIN_DIR/steps/conda-install $BUILD_DIR $CACHE_DIR
$ROOT_DIR/compile-extensions/bin/store_buildpack_metadata $ROOT_DIR $CACHE_DIR

# Experimental post_compile hook.
pushd $BUILD_DIR
source $BIN_DIR/steps/hooks/post_compile
popd

exit 0
fi

Expand Down Expand Up @@ -78,9 +94,6 @@ unset GIT_DIR PYTHONHOME PYTHONPATH
unset RECEIVE_DATA RUN_KEY BUILD_INFO DEPLOY LOG_TOKEN DYNO
unset CYTOKINE_LOG_FILE GEM_PATH

# Syntax sugar.
source $BIN_DIR/utils

# Import collection of warnings.
source $BIN_DIR/warnings

Expand All @@ -93,7 +106,7 @@ EXPORT_PATH="$BIN_DIR/../export"
GUNICORN_PROFILE_PATH="$BUILD_DIR/.profile.d/python.gunicorn.sh"

# We'll need to send these statics to other scripts we `source`.
export BUILD_DIR CACHE_DIR BIN_DIR PROFILE_PATH EXPORT_PATH
export PROFILE_PATH EXPORT_PATH

# Prepend proper environment variables for Python use.
export PATH=/app/.cloudfoundry/python/bin:/app/.cloudfoundry/vendor/bin:$PATH
Expand Down

0 comments on commit 99b8cf2

Please sign in to comment.