Poetry: Support custom location for cache from environment variables like `PIP_CACHE_DIR`

Created on 18 Jul 2018  ·  11Comments  ·  Source: python-poetry/poetry

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.

Issue


I am using GitLab CI/CD. Where I need to customize the cache directory in order to speedup later builds. The cache folder need to be inside the project folder. Currently I see no way to do this.

Proposal

Currently PIP_CACHE_DIR & PIPENV_CACHE_DIR are used by the respective tools. Similar Environment variable name would be good.

Most helpful comment

Poetry, for now, respects XDG environment variables on Linux

so on Linux, setting XDG_CACHE_HOME environment variable will change the location of the Poetry cache.

Also, from my experimentation, if a "poetry.lock" file exists in your project folder, Poetry cache will not be created or modified. Thus "poetry.lock" is in itself a cache if you will. The only cache you have to worry about in this case is the pip cache, which as mentioned above can be switched via PIP_CACHE_DIR

All 11 comments

Isn't settings.virtualenvs.in-project what you're looking for?

Nope that is the virtualenv location. Here I want to change the location where poetry caches the downloaded/built packages/wheels.

@jnoortheen you can set it directly from pip configuration

https://stackoverflow.com/a/52029442/740825 just use a path instead of false and check the documentation for various places to set pip's config.

@jnoortheen you can set it directly from pip configuration

https://stackoverflow.com/a/52029442/740825 just use a path instead of false and check the documentation for various places to set pip's config.

It's for pip! But what about poetry cache?

aah,I get it now… it seems like this is a new feature for a new setting.

you want to customize the location of (what in macOS) defaults to ~/Library/Caches/pypoetry/cache is that right??

For my case it is a docker container what i build and want to decrase build time by store cache outside of container.

I am pretty sure this setting doesn't exist.

However you might be able to work around this by locating the path inside the docker image and making that a docker volume. I imagine it will be in the same folder as the default virtualenv path.

Poetry, for now, respects XDG environment variables on Linux

so on Linux, setting XDG_CACHE_HOME environment variable will change the location of the Poetry cache.

Also, from my experimentation, if a "poetry.lock" file exists in your project folder, Poetry cache will not be created or modified. Thus "poetry.lock" is in itself a cache if you will. The only cache you have to worry about in this case is the pip cache, which as mentioned above can be switched via PIP_CACHE_DIR

@goldslope Last time I used poetry, it created its own cache folder inside ~/.cache/pypoetry after downloading packages. It doesn't use pip for downloading/caching. Has this been changed?

@jnoortheen
if you have Mac/Linux,

run "export PIP_CACHE_DIR=my/test/folder/pip_cache"

then run "poetry install" or "poetry update"

you should find that your test folder gets created and populated

@goldslope I checked it with poetry(0.12.11). Now it respects PIP_CACHE_DIR variable and doesn't create ~/.cache/pypoetry completely if lock file is available. Since we commit lock file to repo this issue is no longer valid and one can use PIP_CACHE_DIR to set the location for caching builds.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexlatchford picture alexlatchford  ·  3Comments

jbarlow83 picture jbarlow83  ·  3Comments

mozartilize picture mozartilize  ·  3Comments

sobolevn picture sobolevn  ·  3Comments

EdgyEdgemond picture EdgyEdgemond  ·  3Comments