Skip to content

Commit

Permalink
[chore] fix pyenv download cache (#997)
Browse files Browse the repository at this point in the history
* [chore] fix pyenv download cache

* fix

Co-authored-by: Min Xu <min.xu.public@gmail.com>
  • Loading branch information
min-xu-ai and flying-x committed May 27, 2022
1 parent c4af33b commit 2bd85c0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,34 @@ commands:
version:
type: string
steps:
# Cache the pyenv download directory to avoid re-downloading over and over.
- restore_cache:
keys:
- cache-key-pyenv-3-9-7-v1

- run:
name: Setup pyenv
# We used to use the following commands to update pyenv.
# git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update
# pyenv update
# However, it is not deterministic since pyenv is being updated.
# It is now fixed to a version. (v2.3.0 is broken since it cause bash to fail when it try to do "eval $(pyenv init -)")
#
# We use "-sf" to skip already installed version after cache restoring the pyenv dir. This should avoid redoing
# downloading and installing. The key name has a "v1" in the end so that we can debug and try different cache objects
# while doing development.
command: |
cd /opt/circleci/.pyenv/
git remote update
git checkout v2.2.0
pyenv install -f <<parameters.version>>
pyenv install -sf <<parameters.version>>
pyenv global <<parameters.version>>
- save_cache:
paths:
- /opt/circleci/.pyenv
key: cache-key-pyenv-3-9-7-v1

# -------------------------------------------------------------------------------------
# Jobs to run
# -------------------------------------------------------------------------------------
Expand Down

0 comments on commit 2bd85c0

Please sign in to comment.