为pip安装缓存远程存储库 [英] Caching remote repository for pip installs
问题描述
在我的pi需求文件中,我需要各种回购的特定提交,即:
git + http:// github .com / frankban / django-endless-pagination.git @ 725bde91db#egg = django-endless-pagination
我遇到的问题是,它明显需要点子才能在每次安装时重新克隆repo,而完全忽略默认的下载缓存。
有什么方法吗?要求这个回购缓存在本地?
或者,或者,最好的解决方案是将其封装并保持本地可用?
您可以做两件事:使用可编辑安装,或者使用 -e
开关将导致> pip
将资源库克隆到virtualenv的 src
子目录中;您可以在每次重新安装时重新使用该副本:
pip install -e -r requirements.txt
然后Pip每次重新运行命令时重新使用现有的源代码(从git更新,而不是或者,因为安装使用了实际的工作目录,所以你可以在 src /目录中使用
代替。 git pull
django-endless-pagination
您可以将pip安装的结果缓存为 Python Wheel :
pip wheel - wheel-dir = / tmp / wheelhouse -r requirements.txt
这将安装所有要求并为 / tmp / wheelhouse
中的每个要求创建轮子。然后,您可以重新使用控制台进行后续安装:
pip install --use-wheel --no-index - find-links = / tmp / wheelhouse -r requirements.txt
车轮不会从但是。
In my pi requirements file, I require specific commits of various repos, ie:
git+http://github.com/frankban/django-endless-pagination.git@725bde91db#egg=django-endless-pagination
The problem I'm having with this is that it apparently requires pip to clone the repo anew for every install, ignoring the default download cache entirely.
Are there any ways to require this repo to be cached locally? Or, alternately, what is the best solution to package this up and keep the package locally available?
You can do two things: use an editable install, or cache the result of the install as a wheel.
Using the -e
switch causes pip
to clone the repository into the src
subdirectory of your virtualenv; you can then reuse that copy each time you want to re-install:
pip install -e -r requirements.txt
Pip then just re-uses the existing source each time you re-run the command (updating from git rather than pulling in a completely new copy of the repo), or, since the installation uses the actual working directory, you can just use git pull
in src/django-endless-pagination
instead.
You can cache the result of the pip install as a Python Wheel:
pip wheel --wheel-dir=/tmp/wheelhouse -r requirements.txt
This installs all the requirements and creates wheels for each in /tmp/wheelhouse
. You can then re-use the wheelhouse for subsequent installs:
pip install --use-wheel --no-index --find-links=/tmp/wheelhouse -r requirements.txt
The wheels won't be updated from the repository however.
这篇关于为pip安装缓存远程存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!