3f8800832a
-----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJYk8+9AAoJEBty/58O8cX8LdIH+wU/VrEVs0XYohiL6DUgabzs 112U3UUihH5xMc/ca9Tarx+XwEvfMZkwYN2Qr0JoRJjmSt2AL6AezUhGSV+98vaY iQEccaFDFYlyDHm4V2r7N1xwS0B3mx87FPqVQQSUKlc3JsQxCy4o9RtD9aM8Gvqy +gAxMxL3p3O131K0Rvb0U5lC1FLgft9SuljCV8i5nU4/HdoryD6hedz2/ss8a9KG KKEdBKvPBKn73+nb8peQD/VXpej9C31r87q5VEjUsZkJ7gduY/qYLlGGgoBQqAXN WQ/ef1RkQKW5ba2jsjnk7fdOrA0+wYENxorR2WecuZbe2ieXw6fP3lYiD6VeWsM= =IUuh -----END PGP SIGNATURE----- Merge tag '1.27.0' into merge-branch Release 1.27.0 Change-Id: I9f6948636cae6d375d1d8315976504021f5a3bbb
72 lines
2.7 KiB
Python
Executable file
72 lines
2.7 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from __future__ import print_function
|
|
|
|
import os.path
|
|
|
|
|
|
def main():
|
|
home = os.path.expanduser("~")
|
|
backup_configs(home)
|
|
indices = []
|
|
if (os.environ.get('DIB_PYPI_MIRROR_URL') or
|
|
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)))
|
|
else:
|
|
indices = ['file:///tmp/pypi']
|
|
print('WARNING: You are using the pypi element but no pypi mirror is '
|
|
'defined via the PYPI_MIRROR_URL env variable')
|
|
easy_index = indices[-1]
|
|
use_pypi_python_org = True
|
|
if os.environ.get('DIB_OFFLINE'):
|
|
use_pypi_python_org = False
|
|
if os.environ.get('DIB_NO_PYPI_PIP'):
|
|
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 open(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 open(home + '/.pydistutils.cfg', 'wt') as output:
|
|
output.write('[easy_install]\n')
|
|
output.write('index_url = %s\n' % (easy_index,))
|
|
|
|
|
|
def backup_configs(home):
|
|
pip_dir = home + '/.pip'
|
|
if not os.path.exists(pip_dir):
|
|
os.mkdir(pip_dir)
|
|
if os.path.exists(pip_dir + '/pip.conf'):
|
|
os.rename(pip_dir + '/pip.conf', pip_dir + '/pip.conf.orig')
|
|
if os.path.exists(home + '/.pydistutils.cfg'):
|
|
os.rename(home + '/.pydistutils.cfg', home + '/.pydistutils.cfg.orig')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|