From f7c422e07d7351a3cc16110668406e53ae4ccf8f Mon Sep 17 00:00:00 2001 From: Casey Faist Date: Thu, 19 Mar 2020 16:20:30 -0400 Subject: [PATCH] test clear cache and cache requirements.txt --- bin/steps/pip-install | 6 ++++++ bin/steps/python | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/steps/pip-install b/bin/steps/pip-install index e47c670..6159a07 100755 --- a/bin/steps/pip-install +++ b/bin/steps/pip-install @@ -47,6 +47,8 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then if [ ! -f "$BUILD_DIR/.heroku/python/bin/pip" ]; then exit 1 fi + + /app/.heroku/python/bin/pip install -r "$BUILD_DIR/requirements.txt" --exists-action=w --src=/app/.heroku/src --disable-pip-version-check | tee "$WARNINGS_LOG" | cleanup | indent PIP_STATUS="${PIPESTATUS[0]}" set -e @@ -60,6 +62,10 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then # Cache pip packages ourselves ## TODO: Update to cache pip's built-in cache + + # Update cached version of requirements.txt + cp -R $BUILD_DIR/requirements.txt "$CACHE_DIR/.heroku/requirements.txt" + cp requirements.txt .heroku/python/requirements-declared.txt /app/.heroku/python/bin/pip freeze --disable-pip-version-check > .heroku/python/requirements-installed.txt diff --git a/bin/steps/python b/bin/steps/python index 8d906ff..5d2d0f3 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -96,6 +96,15 @@ if [ -f .heroku/python-version ]; then fi + +echo "$(diff "$BUILD_DIR/requirements.txt" "$CACHE_DIR/.heroku/requirements.txt")" + +# Remove python dependencies +if [[ ! -f "$CACHE_DIR/.heroku/requirements.txt" ]] || [[ diff "$BUILD_DIR/requirements.txt" "$CACHE_DIR/.heroku/requirements.txt" ]]; then + puts-step "Clearing cached dependencies" + rm -rf .heroku/python +fi + if [ ! "$SKIP_INSTALL" ]; then puts-step "Installing $PYTHON_VERSION" @@ -129,7 +138,7 @@ if ! curl -s "${GETPIP_URL}" -o "$GETPIP_PY" &> /dev/null; then exit 1 fi -# If Pip isn't up to date: +# If a new Python has been installed or Pip isn't up to date: if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then puts-step "Installing pip"