|
6 | 6 | source "$BIN_DIR/utils"
|
7 | 7 | set -e
|
8 | 8 |
|
9 |
| -if [[ -f Pipfile.lock ]]; then |
10 |
| - if [[ -f .heroku/python/Pipfile.lock.sha256 ]]; then |
11 |
| - if [[ $(openssl dgst -sha256 Pipfile.lock) == $(cat .heroku/python/Pipfile.lock.sha256) ]]; then |
12 |
| - # Don't skip installation if there are git deps. |
13 |
| - if ! grep -q 'git' Pipfile.lock; then |
14 |
| - echo "Skipping installation, as Pipfile.lock hasn't changed since last deploy." | indent |
| 9 | +# Previous versions of the buildpack used to cache the checksum of the lockfile to allow |
| 10 | +# for skipping pipenv install if the lockfile was unchanged. However, this is not always safe |
| 11 | +# to do (the lockfile can refer to dependencies that can change independently of the lockfile, |
| 12 | +# for example, when using a local non-editable file dependency), so we no longer ever skip |
| 13 | +# install, and instead defer to pipenv to determine whether install is actually a no-op. |
| 14 | +rm -f .heroku/python/Pipfile.lock.sha256 |
| 15 | + |
| 16 | +if [[ -f Pipfile ]]; then |
| 17 | + # Measure that we're using Pipenv. |
| 18 | + mcount "tool.pipenv" |
| 19 | + |
| 20 | + # Skip installing dependencies using pip later. |
| 21 | + export SKIP_PIP_INSTALL=1 |
15 | 22 |
|
16 |
| - mcount "tool.pipenv" |
17 |
| - export SKIP_PIPENV_INSTALL=1 |
18 |
| - export SKIP_PIP_INSTALL=1 |
19 |
| - fi |
20 |
| - fi |
| 23 | + # Set Pip env vars |
| 24 | + # This reads certain environment variables set on the Heroku app config |
| 25 | + # and makes them accessible to the pip install process. |
| 26 | + # |
| 27 | + # PIP_EXTRA_INDEX_URL allows for an alternate pypi URL to be used. |
| 28 | + if [[ -r "$ENV_DIR/PIP_EXTRA_INDEX_URL" ]]; then |
| 29 | + PIP_EXTRA_INDEX_URL="$(cat "$ENV_DIR/PIP_EXTRA_INDEX_URL")" |
| 30 | + export PIP_EXTRA_INDEX_URL |
| 31 | + mcount "buildvar.PIP_EXTRA_INDEX_URL" |
21 | 32 | fi
|
22 |
| -fi |
23 |
| - |
24 |
| - |
25 |
| -if [ ! "$SKIP_PIPENV_INSTALL" ]; then |
26 |
| - # Pipenv support (Generate requirements.txt with pipenv). |
27 |
| - if [[ -f Pipfile ]]; then |
28 |
| - # Measure that we're using Pipenv. |
29 |
| - mcount "tool.pipenv" |
30 | 33 |
|
31 |
| - # Skip pip install, later. |
32 |
| - export SKIP_PIP_INSTALL=1 |
| 34 | + PIPENV_VERSION=$(get_requirement_version 'pipenv') |
33 | 35 |
|
34 |
| - # Set Pip env vars |
35 |
| - # This reads certain environment variables set on the Heroku app config |
36 |
| - # and makes them accessible to the pip install process. |
37 |
| - # |
38 |
| - # PIP_EXTRA_INDEX_URL allows for an alternate pypi URL to be used. |
39 |
| - if [[ -r "$ENV_DIR/PIP_EXTRA_INDEX_URL" ]]; then |
40 |
| - PIP_EXTRA_INDEX_URL="$(cat "$ENV_DIR/PIP_EXTRA_INDEX_URL")" |
41 |
| - export PIP_EXTRA_INDEX_URL |
42 |
| - mcount "buildvar.PIP_EXTRA_INDEX_URL" |
43 |
| - fi |
| 36 | + /app/.heroku/python/bin/pip install --quiet --disable-pip-version-check --no-cache-dir "pipenv==${PIPENV_VERSION}" |
44 | 37 |
|
45 |
| - PIPENV_VERSION=$(get_requirement_version 'pipenv') |
| 38 | + # Install the test dependencies, for CI. |
| 39 | + if [ "$INSTALL_TEST" ]; then |
| 40 | + puts-step "Installing test dependencies" |
| 41 | + /app/.heroku/python/bin/pipenv install --dev --system --deploy 2>&1 | cleanup | indent |
46 | 42 |
|
47 |
| - /app/.heroku/python/bin/pip install --quiet --disable-pip-version-check --no-cache-dir "pipenv==${PIPENV_VERSION}" |
| 43 | + # Install the dependencies. |
| 44 | + elif [[ ! -f Pipfile.lock ]]; then |
| 45 | + puts-step "Installing dependencies with Pipenv ${PIPENV_VERSION}" |
| 46 | + /app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent |
48 | 47 |
|
49 |
| - # Install the test dependencies, for CI. |
50 |
| - if [ "$INSTALL_TEST" ]; then |
51 |
| - puts-step "Installing test dependencies" |
52 |
| - /app/.heroku/python/bin/pipenv install --dev --system --deploy 2>&1 | cleanup | indent |
| 48 | + else |
| 49 | + pipenv-to-pip Pipfile.lock > requirements.txt |
| 50 | + cp requirements.txt .heroku/python/requirements-declared.txt |
53 | 51 |
|
54 |
| - # Install the dependencies. |
55 |
| - elif [[ ! -f Pipfile.lock ]]; then |
56 |
| - puts-step "Installing dependencies with Pipenv ${PIPENV_VERSION}" |
57 |
| - /app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent |
58 |
| - |
59 |
| - else |
60 |
| - pipenv-to-pip Pipfile.lock > requirements.txt |
61 |
| - cp requirements.txt .heroku/python/requirements-declared.txt |
62 |
| - openssl dgst -sha256 Pipfile.lock > .heroku/python/Pipfile.lock.sha256 |
63 |
| - |
64 |
| - puts-step "Installing dependencies with Pipenv ${PIPENV_VERSION}" |
65 |
| - /app/.heroku/python/bin/pipenv install --system --deploy 2>&1 | indent |
66 |
| - fi |
| 52 | + puts-step "Installing dependencies with Pipenv ${PIPENV_VERSION}" |
| 53 | + /app/.heroku/python/bin/pipenv install --system --deploy 2>&1 | indent |
67 | 54 | fi
|
68 |
| -else |
69 |
| - export SKIP_PIP_INSTALL=1 |
70 |
| - pipenv-to-pip Pipfile.lock > requirements.txt |
71 | 55 | fi
|
0 commit comments