I would like to cache poetry installation in .circleci
The command is as follows:
curl -sSL https://install.python-poetry.org | python3 -
which creates a bin in
/home/circleci/.local/bin/poetry
which actually links to
/home/circleci/.local/share/pypoetry/venv/bin/poetry whereby /home/circleci/.local/share/pypoetry gets created by the installation.
After installation, doing poetry config --list results in
cache-dir = "/home/circleci/.cache/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/circleci/.cache/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true
In my config.yml I tried many variations of the following:
- restore_cache: # **restores saved dependency cache if the Branch key template or requirements.txt files have not changed since the previous run**
key: deps1-{{ .Branch }}-{{ checksum "pyproject.toml" }}
paths:
- "/home/circleci/.cache/pypoetry"
- run:
name: Install poetry
command: |
curl -sSL https://install.python-poetry.org | python3 -
- save_cache: # ** special step to save dependency cache **
key: deps1-{{ .Branch }}-{{ checksum "pyproject.toml" }}
paths:
- "/home/circleci/.cache/pypoetry"
Where in the paths: key I tried
- /home/circleci/.cache/pypoetry
- /home/circleci/.cache
- /home/circleci/.local/bin/
- /home/circleci/.local/share/pypoetry
- /home/circleci/.local/share/pypoetry/venv/bin
Caching in .circleci itself works well, for example caching the libraries installed by poetry, works flawlessly
- restore_cache: # **restores saved dependency cache if the Branch key template or requirements.txt files have not changed since the previous run**
key: deps1-{{ .Branch }}-{{ checksum "poetry.lock" }}
paths:
- "/root/.cache/pypoetry/virtualenvs"
- run:
name: Install dependencies with poetry
command: |
poetry install
- save_cache: # ** special step to save dependency cache **
key: deps1-{{ .Branch }}-{{ checksum "poetry.lock" }}
paths:
- "/root/.cache/pypoetry/virtualenvs"