From 533896812f087b75f27059aca23334791095ce9b Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 19 Feb 2015 15:11:52 -0800 Subject: [PATCH] Allow setting DIB_PIP_RETRIES Pip now supports retries on failure. If setting multiple pypi mirrors a fallback will not occure until the failures have finished for the first mirror. This can cause a substantial delay if mirror fallback occurs a lot. Change-Id: Iad37a9015a2d5c861a345a111bd1725b965a42d3 --- elements/pypi/README.rst | 6 ++++++ elements/pypi/pre-install.d/00-configure-pypi-mirror | 3 +++ 2 files changed, 9 insertions(+) diff --git a/elements/pypi/README.rst b/elements/pypi/README.rst index e0dfc17f8..ecdf1ad95 100644 --- a/elements/pypi/README.rst +++ b/elements/pypi/README.rst @@ -24,10 +24,16 @@ the first mirror to be used, the last listed mirror is used as the pydistutils index. NB: The sort order for these variables is a simple string sort - if you have more than 9 additional mirrors, some care will be needed. +You can also set the number of retries that occur on failure by setting the +DIB\_PIP\_RETRIES environment variable. If setting fallback pip mirrors you +typically want to set this to 0 to prevent the need to fail multiple times +before falling back. + A typical use of this element is thus: export DIB\_PYPI\_MIRROR\_URL=http://site/pypi/Ubuntu-13.10 export DIB\_PYPI\_MIRROR\_URL\_1=http://site/pypi/ export DIB\_PYPI\_MIRROR\_URL\_2=file:///tmp/pypi +export DIB\_PIP\_RETRIES=0 [devpi-server](https://git.openstack.org/cgit/openstack-infra/pypi-mirro://pypi.python.org/pypi/devpi-server) can be useful in making a partial PyPI mirror suitable for building images. For diff --git a/elements/pypi/pre-install.d/00-configure-pypi-mirror b/elements/pypi/pre-install.d/00-configure-pypi-mirror index c1d3b55bc..b2124d0b7 100755 --- a/elements/pypi/pre-install.d/00-configure-pypi-mirror +++ b/elements/pypi/pre-install.d/00-configure-pypi-mirror @@ -44,10 +44,13 @@ def main(): use_pypi_python_org = False if use_pypi_python_org: indices.append('https://pypi.python.org/simple') + retries = os.environ.get('DIB_PIP_RETRIES') with file(home + '/.pip/pip.conf', 'wt') as output: output.write('[global]\n') output.write('log = %s/pip.log\n' % (home,)) output.write('index-url = %s\n' % (indices[0],)) + if retries is not None: + output.write('retries = %s\n' % retries) for index in indices[1:]: output.write('extra-index-url = %s\n' % (index,)) with file(home + '/.pydistutils.cfg', 'wt') as output: