PyPI local cache for Jenkins/local builds

2019-05-06 19:08发布

问题:

I have a Jenkins instance which builds my project with its attendant PyPI packages from requirements.txt. However, like with TravisCI builds, building from scratch each time is very time intensive, and means builds take >4-5mins which is much slower than would be ideal.

What I'm looking for is a way to cache downloaded packages locally, so when a build with the same dependencies is started, rather than having to get from PyPI it can just fetch locally, when a change in version occurs, it can fetch the upstream package as it does now.

Is there such a project out there, as Googling this evening hasn't revealed much.

回答1:

pip supports this out of the box

pip install --download-cache=DIR

if an existing file is requested, it's read from the cache. This can also be done with an environment variable PIP_DOWNLOAD_CACHE;



回答2:

You can an egg proxy cache like

http://pypi.python.org/pypi/collective.eggproxy

This acts like a local proxy for all downloaded eggs making Jenkins more robust e.g. against timeouts which happen very often with PyPI.

Aside from that you can use the PYCACHE feature of setuptools. See

What is the Python egg cache (PYTHON_EGG_CACHE)?