Merge "Namespace PYPI_MIRROR_URL vars with DIB"

This commit is contained in:
Jenkins 2015-02-19 18:39:14 +00:00 committed by Gerrit Code Review
commit 2f4d5be6f3
2 changed files with 22 additions and 14 deletions

View File

@ -16,18 +16,18 @@ To disable the pypi.python.org index without using --offline (e.g. when working
behind a corporate firewall that prohibits pypi.python.org) set behind a corporate firewall that prohibits pypi.python.org) set
DIB\_NO\_PYPI\_PIP to any non-empty value. DIB\_NO\_PYPI\_PIP to any non-empty value.
To use an arbitrary mirror set PYPI\_MIRROR\_URL=http[s]://somevalue/ To use an arbitrary mirror set DIB\_PYPI\_MIRROR\_URL=http[s]://somevalue/
Additional mirrors can be added by exporting PYPI\_MIRROR\_URL\_1=... etc. Only Additional mirrors can be added by exporting DIB\_PYPI\_MIRROR\_URL\_1=... etc.
the one mirror can be used by easy-install, but since wheels need to be in the Only the one mirror can be used by easy-install, but since wheels need to be in
first mirror to be used, the last listed mirror is used as the pydistutils 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 index. NB: The sort order for these variables is a simple string sort - if you
you have more than 9 additional mirrors, some care will be needed. have more than 9 additional mirrors, some care will be needed.
A typical use of this element is thus: A typical use of this element is thus:
export PYPI\_MIRROR\_URL=http://site/pypi/Ubuntu-13.10 export DIB\_PYPI\_MIRROR\_URL=http://site/pypi/Ubuntu-13.10
export PYPI\_MIRROR\_URL\_1=http://site/pypi/ export DIB\_PYPI\_MIRROR\_URL\_1=http://site/pypi/
export PYPI\_MIRROR\_URL\_2=file:///tmp/pypi export DIB\_PYPI\_MIRROR\_URL\_2=file:///tmp/pypi
[devpi-server](https://git.openstack.org/cgit/openstack-infra/pypi-mirro://pypi.python.org/pypi/devpi-server) [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 can be useful in making a partial PyPI mirror suitable for building images. For
@ -41,9 +41,9 @@ instance:
* Re-export your variables to point at the new mirror: * Re-export your variables to point at the new mirror:
export PYPI\_MIRROR\_URL=http://machinename:3141/ export DIB\_PYPI\_MIRROR\_URL=http://machinename:3141/
unset PYPI\__MIRROR\_URL\_1 unset DIB\_PYPI\__MIRROR\_URL\_1
unset PYPI\__MIRROR\_URL\_1 unset DIB\_PYPI\__MIRROR\_URL\_2
The next time packages are installed, they'll be cached on the local devpi The next time packages are installed, they'll be cached on the local devpi
server; subsequent runs pointed at the same mirror will use the local cache if server; subsequent runs pointed at the same mirror will use the local cache if

View File

@ -21,8 +21,16 @@ def main():
home = os.path.expanduser("~") home = os.path.expanduser("~")
backup_configs(home) backup_configs(home)
indices = [] indices = []
if os.environ.get('PYPI_MIRROR_URL'): if (os.environ.get('DIB_PYPI_MIRROR_URL') or
candidates = [k for k in os.environ if k.startswith('PYPI_MIRROR_URL')] os.environ.get('PYPI_MIRROR_URL')):
candidates = [k for k in os.environ if
k.startswith('DIB_PYPI_MIRROR_URL')]
back_compat = [k for k in os.environ if
k.startswith('PYPI_MIRROR_URL')]
if len(back_compat) > 0:
print('DEPRECATION WARNING: Please use DIB_PYPI_MIRROR_URL* rather'
' than PYPI_MIRROR_URL*')
candidates += back_compat
indices = list(map(os.environ.get, sorted(candidates))) indices = list(map(os.environ.get, sorted(candidates)))
else: else:
indices = ['file:///tmp/pypi'] indices = ['file:///tmp/pypi']