Seeing the same issue (and the discussion board help actually found this topic to offer me!)
I can’t use a composite key that includes, say, {{ checksum ".venv/bin/python" }}
, because the restore job doesn’t yet have that file to compute the checksum on.
This basic idea works for me:
commands:
checkout-and-restore-deps:
steps:
- checkout
- run: python --version > python_version
- restore_cache:
keys:
- pipenv-v3-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "python_version" }}
- pipenv-v3-{{ .Branch }}
- pipenv-v3
jobs:
restore-deps:
executor: python
environment: &common-env
- PIPENV_VENV_IN_PROJECT: 1
- PIPENV_NOSPIN: "TRUE"
steps:
- checkout-and-restore-deps
- run:
name: Wipe venv in case of stale symlink to old pyenv version
command: |
if [[ -d .venv/bin ]] && [[ ! -e .venv/bin/python ]]
then pipenv --rm
fi
- run: pipenv sync --dev
- save_cache:
key: pipenv-v3-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "python_version" }}
paths:
- ".venv"