From f0ea766900ad71baab14db866354fef4f68322d1 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 1 Nov 2016 12:35:25 -0400 Subject: [PATCH 1/9] basic test-compile script --- bin/test-compile | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 bin/test-compile diff --git a/bin/test-compile b/bin/test-compile new file mode 100755 index 0000000..a1d0b98 --- /dev/null +++ b/bin/test-compile @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +DISABLE_COLLECTSTATIC=1 "$(dirname ${0:-})/compile" "$1" "$2" "$3" \ No newline at end of file From 40daa84ccc65426c525abdb7d5ee45016044190f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 1 Nov 2016 12:41:17 -0400 Subject: [PATCH 2/9] syntax sugar and test-requirements.txt --- bin/test-compile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/test-compile b/bin/test-compile index a1d0b98..50d1933 100755 --- a/bin/test-compile +++ b/bin/test-compile @@ -1,3 +1,11 @@ #!/usr/bin/env bash -DISABLE_COLLECTSTATIC=1 "$(dirname ${0:-})/compile" "$1" "$2" "$3" \ No newline at end of file +# Syntax sugar. +BIN_DIR=$(cd $(dirname $0); pwd) # absolute path +source $BIN_DIR/utils + +DISABLE_COLLECTSTATIC=1 "$(dirname ${0:-})/compile" "$1" "$2" "$3" + +if [[ -f "$1/requirements-test.txt" ]]; then + /app/.heroku/python/bin/pip install -r requirements-test.txt --exists-action=w --src=./.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | cleanup | indent +fi From 5cd4245412f3a2c78e0bfa39169bbcbb969f6d0e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 1 Nov 2016 12:45:27 -0400 Subject: [PATCH 3/9] Skip copying the code if we're already in the right spot --- bin/compile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 56335c8..43e0037 100755 --- a/bin/compile +++ b/bin/compile @@ -92,7 +92,10 @@ if [[ ! "$DOCKER_BUILD" ]]; then # Copy Application code in. bpwatch start appdir_stage - deep-cp $BUILD_DIR $APP_DIR + # Skip copying the code if we're already in the right spot. + if [[ $BUILD_DIR != "/app" ]]; then + deep-cp $BUILD_DIR $APP_DIR + fi bpwatch stop appdir_stage fi From 521bb00247071e288ffd1d21a05346496cc77844 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 1 Nov 2016 13:18:53 -0400 Subject: [PATCH 4/9] export functionality --- bin/compile | 1 + bin/utils | 3 +++ 2 files changed, 4 insertions(+) diff --git a/bin/compile b/bin/compile index 43e0037..833d415 100755 --- a/bin/compile +++ b/bin/compile @@ -106,6 +106,7 @@ BUILD_DIR=$APP_DIR # Set up outputs under new context PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh" +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`. diff --git a/bin/utils b/bin/utils index dd15c6e..a4dc20f 100755 --- a/bin/utils +++ b/bin/utils @@ -39,11 +39,14 @@ puts-cmd() { # Usage: $ set-env key value set-env() { echo "export $1=$2" >> $PROFILE_PATH + echo "export $1=$2" >> $EXPORT_PATH } # Usage: $ set-default-env key value set-default-env() { echo "export $1=\${$1:-$2}" >> $PROFILE_PATH + echo "export $1=\${$1:-$2}" >> $EXPORT_PATH + } # Usage: $ un-set-env key From f8a1761165b1872f68bdf0569ca3490ebe348b22 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 2 Nov 2016 11:20:09 -0400 Subject: [PATCH 5/9] export path fix --- bin/compile | 2 +- bin/utils | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/compile b/bin/compile index 833d415..73e8b5a 100755 --- a/bin/compile +++ b/bin/compile @@ -110,7 +110,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 BUILD_DIR CACHE_DIR BIN_DIR PROFILE_PATH EXPORT_PATH # Prepend proper environment variables for Python use. export PATH=$BUILD_DIR/.heroku/python/bin:$BUILD_DIR/.heroku/vendor/bin:$PATH diff --git a/bin/utils b/bin/utils index a4dc20f..9ce1721 100755 --- a/bin/utils +++ b/bin/utils @@ -46,7 +46,6 @@ set-env() { set-default-env() { echo "export $1=\${$1:-$2}" >> $PROFILE_PATH echo "export $1=\${$1:-$2}" >> $EXPORT_PATH - } # Usage: $ un-set-env key From ab724138c1da73073e3b3d1b98de97731d43d92c Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 2 Nov 2016 13:59:33 -0400 Subject: [PATCH 6/9] another approach --- bin/compile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/compile b/bin/compile index 73e8b5a..6253519 100755 --- a/bin/compile +++ b/bin/compile @@ -54,6 +54,7 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop [ ! "$SLUG_ID" ] && SLUG_ID="defaultslug" [ ! "$REQUEST_ID" ] && REQUEST_ID=$SLUG_ID [ ! "$STACK" ] && STACK=$DEFAULT_PYTHON_STACK +[[ $BUILD_DIR != "/app" ]] && SKIP_MOVE_BUILD=$1 # Sanitizing environment variables. unset GIT_DIR PYTHONHOME PYTHONPATH @@ -78,7 +79,7 @@ APP_DIR='/app' TMP_APP_DIR=$CACHE_DIR/tmp_app_dir # Skip these steps for Docker. -if [[ ! "$DOCKER_BUILD" ]]; then +if [[ ! "$SKIP_MOVE_BUILD" ]]; then # Copy Anvil app dir to temporary storage... bpwatch start anvil_appdir_stage @@ -92,10 +93,7 @@ if [[ ! "$DOCKER_BUILD" ]]; then # Copy Application code in. bpwatch start appdir_stage - # Skip copying the code if we're already in the right spot. - if [[ $BUILD_DIR != "/app" ]]; then - deep-cp $BUILD_DIR $APP_DIR - fi + deep-cp $BUILD_DIR $APP_DIR bpwatch stop appdir_stage fi @@ -256,7 +254,7 @@ bpwatch start dump_cache bpwatch stop dump_cache # Fin. -if [[ ! "$DOCKER_BUILD" ]]; then +if [[ ! "$SKIP_MOVE_BUILD" ]]; then bpwatch start appdir_commit deep-rm $ORIG_BUILD_DIR From e427d5111e698616385443f6e4f3d1bbf7f2161e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 2 Nov 2016 14:00:07 -0400 Subject: [PATCH 7/9] debug --- bin/compile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/compile b/bin/compile index 6253519..e0d2ed8 100755 --- a/bin/compile +++ b/bin/compile @@ -55,6 +55,9 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop [ ! "$REQUEST_ID" ] && REQUEST_ID=$SLUG_ID [ ! "$STACK" ] && STACK=$DEFAULT_PYTHON_STACK [[ $BUILD_DIR != "/app" ]] && SKIP_MOVE_BUILD=$1 +echo $SKIP_MOVE_BUILD +echo $BULD_DIR +echo '^^^^' # Sanitizing environment variables. unset GIT_DIR PYTHONHOME PYTHONPATH From 9c2b033042cc3eb64d50ec220801d72887898565 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 2 Nov 2016 14:04:39 -0400 Subject: [PATCH 8/9] proper debug --- bin/compile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index e0d2ed8..82ed7a5 100755 --- a/bin/compile +++ b/bin/compile @@ -55,8 +55,9 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop [ ! "$REQUEST_ID" ] && REQUEST_ID=$SLUG_ID [ ! "$STACK" ] && STACK=$DEFAULT_PYTHON_STACK [[ $BUILD_DIR != "/app" ]] && SKIP_MOVE_BUILD=$1 + echo $SKIP_MOVE_BUILD -echo $BULD_DIR +echo $BUILD_DIR echo '^^^^' # Sanitizing environment variables. From bbbadc83e40d8d3e1b331175d35555f8c18a98e6 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 2 Nov 2016 14:06:50 -0400 Subject: [PATCH 9/9] is /app --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 82ed7a5..f700ed1 100755 --- a/bin/compile +++ b/bin/compile @@ -54,7 +54,7 @@ export PATH=$PATH:$ROOT_DIR/vendor/pip-pop [ ! "$SLUG_ID" ] && SLUG_ID="defaultslug" [ ! "$REQUEST_ID" ] && REQUEST_ID=$SLUG_ID [ ! "$STACK" ] && STACK=$DEFAULT_PYTHON_STACK -[[ $BUILD_DIR != "/app" ]] && SKIP_MOVE_BUILD=$1 +[[ $BUILD_DIR == "/app" ]] && SKIP_MOVE_BUILD=$1 echo $SKIP_MOVE_BUILD echo $BUILD_DIR