sha*_*ker 11 python caching travis-ci requirements.txt pipenv
关于缓存的Travis 文档没有具体提到如何缓存从pipenv的Pipfile安装的python依赖项,而不是pip通常的requirements.txt.我尝试设置每个文档的pip缓存,但是构建时间根本没有改进,我看到pipenv在每次运行时安装它的deps.
这是我目前使用的语法 - 正确的语法是什么?(或甚至支持?)
language: python
python:
- "3.6"
cache: pip
cache:
directories:
- proj/static/node_modules
- $HOME/.cache/pip
Run Code Online (Sandbox Code Playgroud)
小智 7
检查文档https://pipenv.readthedocs.io/en/latest/advanced/
您可以使用环境变量 PIPENV_CACHE_DIR 告诉 Pipenv 在何处缓存文件,然后将其包含在 cache.directories 数组中。
我在 gitlab-ci.yml 配置上执行此操作(语法与 travis-ci 非常相似)。我还缓存了 virtualenv,这大大加快了构建时间。
我的 gitlab-ci.yml 实际上看起来像这样:
# WORKON_HOME sets where pipenv will place the virtualenv. We do this so that we can capture
# the environment in the cache for gitlab-ci.
# PIP_CACHE_DIR tells pip to cache our pip packages in the same path, so that we also
# cache the downloads.
variables:
WORKON_HOME: .pipenv/venvs
PIP_CACHE_DIR: .pipenv/pipcache
# Make sure gitlab-ci knows to always cache the .pipenv path
cache:
key: pipenv
paths:
- .pipenv
Run Code Online (Sandbox Code Playgroud)