How do I use easy_install and buildout when pypi is down?

不打扰是莪最后的温柔 提交于 2019-12-02 19:27:46

Here are instructions on how to setup your own PyPi mirror. The homepage of this project is here. There also seems to be a growing number of mirrors out there.

For instructions on how to setup your own package index, check out this blog post where one solution is explained at the end. Then you can also host your own internal packages in there. The advantage is also that the versions are fixed that way. (For a way to pin the versions directly in buildout, check out this post).

If there is only metadata on PyPI and the archive is stored somewhere else you might of course copy that over to your index as well. If you just use a PyPI mirror I assume that you still need access to these servers.

You can also use a mirror. Put this in the "[global]" section of "~/.pip/pip.conf":

index-url = http://d.pypi.python.org/simple/

This is a recent feature as announced here.

This page shows how to use the alternate mirror mentioned in @moraes post, but for easy_install, buildout and virtualenv as well as pip:

http://jacobian.org/writing/when-pypi-goes-down/

In case of zc.buildout: use its local download caching features. There are mostly three things to cache:

For all three we need to tweak the global configuration and set a cache folder for the extends and one for eggs and other downloads.

In your home folder create a .buildout folder.

In this folder create the folders extends-cache and downloads

In .buildout create a file default.cfg with:

[buildout]  
extends-cache = /home/USERNAME/.buildout/extends-cache 
download-cache = /home/USERNAME/.buildout/downloads

so you have:

.buildout/
├── default.cfg
├── downloads
└── extends-cache

Thats it. Make sure to not override these two variables from default.cfg in your specific buildout. After first successful run of buildout subsequent runs are running in offline mode ./bin/buildout -o.

As a side effect buildout is much faster if used in offline mode, i.e. when no new downloads are expected but some configuration changed

Beside this it makes sense to run your own pypi-mirror. As another source of information you might be interested in the article I wrote some time ago about this topic: http://bluedynamics.com/articles/jens/setup-z3c.pypimirror

T. Kim Nguyen

Configure index in buildout.cfg, e.g.

[buildout]
index = http://a.pypi.python.org/
find-links = 

More mirrors on : http://www.pypi-mirrors.org/

PyPI has had mirroring since mid 2010 http://pypi.python.org/mirrors

For the packages, that you need to install in your virtualenv usually through a requirements.txt (or may be individually), you have to override your pip.conf file, usually located at ~/.pip/pip.conf

In your pip.conf file:

[global]
index-url=https://pypi.python.org/simple/

[install]
trusted-host=pypi.python.org

Here you can provide the url of your own custom version of pypi if needed.

If you wish to also use another pypi server while creating virtualenv through easy_install you need to override pydistutils.cfg file usually located at ~/pydistutils.cfg

In pydistutils.cfg file:

[easy_install]
index-url=https://pypi.python.org/simple/

This would ensure to create your venv with the url of pypi mentioned in pydistutils.cfg. Here, we're telling easy_install to use https://pypi.python.org/simple/ for creating venvs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!