Reload Original PagePrint PageEmail Page

Using a local cache for pip packages

I do a lot of development without an internet connection1, so being able to install packages into a virtual environment without a connection to PyPI is pretty useful.

I've got a couple of aliases in my .bashrc which help with this2:

alias pipcache='pip install --download ${HOME}/.pip-packages'
alias pipinstall='pip install --no-index --find-links=file://${HOME}/.pip-packages/'

The first downloads the packages to my local cache, the second installs them from the cache.

Usage is probably fairly obvious:

pipcache Django==1.5 # Put Django-1.5.tar.gz in ~/.pip-packages
pipinstall Django==1.5 # Install ~/.pip-packages/Django-1.5.tar.gz

pipcache -r requirements.txt # Cache all the requirements of a project
pipinstall -r requirements.txt # Install all requirements from the cache

It's perfectly possible to cache multiple versions of the same package3, which is useful for being able to test upgrading to newer releases, whilst still being able to revert to the previously pinned package if you find nothing works.

Since I mostly use a fairly small set of packages, this means I can start up a brand new virtualenv and I'm very likely to have everything I need without going to PyPI. Not having to download large packages ::...


免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::